RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a sword combat system"
-- server script local sword = script.Parent local function onEquip(character) local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then humanoid.Died:Connect(function() sword:Destroy() end) end end sword.Equipped:Connect(onEquip) local function onUnequip(character) sword:Destroy() end sword.Unequipped:Connect(onUnequip) local function onAttack(mouse) local character = mouse.Player.Character local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then local target = mouse.Hit.Parent if target and target:IsA("Model") and target.Name ~= character.Name then local humanoid = target:FindFirstChildOfClass("Humanoid") if humanoid then humanoid.Health = humanoid.Health - 10 end end end end sword.Activated:Connect(onAttack)