RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a advanced swordscript for a sword tool"
-- local script local sword = script.Parent local attack = false sword.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() attack = true end) mouse.Button1Up:Connect(function() attack = false end) end) sword.Unequipped:Connect(function() attack = false end) game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character.ChildAdded:Connect(function(child) if child:IsA("Tool") and child.Name == "Sword" then child.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() attack = true end) mouse.Button1Up:Connect(function() attack = false end) end) child.Unequipped:Connect(function() attack = false end) end end) end) end) while wait(0.1) do if attack then local ray = Ray.new(sword.Handle.Position, (sword.Handle.CFrame.lookVector * 10)) local hit, position = workspace:FindPartOnRayWithIgnoreList(ray, {sword.Parent}) if hit and hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid:TakeDamage(10) end end end