I'm trying to make a simple sword that disables a touch connection after it hits a player, but whenever I try this, it can only be fired once. Is there a way to do this?
For example:
local Blade = script.Parent.Blade
local Remote = Tool:WaitForChild("RemoteEvent")
Remote.OnServerEvent:Connect(function(player)--This fires when the client clicks their mouse.
Clicked = true
end)
function Slash(Hit)
if Clicked then
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid:TakeDamage(20)
Connection:Disconnect()
Clicked = false
end
end
end
Connection = Blade.Touched:Connect(Slash)

1 comment
You are better off using a debounce http://wiki.roblox.com/index.php?title=Debounce.