local player = game.Players.LocalPlayer local handle = script.Parent.Handle local debounce = false handle.Touched:Connect(function(hit) if not debounce and hit and hit.Parent.Humanoid then debounce = true hit.Parent.Humanoid:TakeDamage(40) wait(10) debounce = false end end)
This is a local script called Damage in my tool How would I make the handle disappear after hit
Also please feel free for tips and advice, will gladly accept them.
Your code wont replicate; you are using a localscript to damage which will not work but here Add a remote event into your tool and a Serverscript.
LocalScript:
local tool = script.Parent local handle = tool:WaitForChild("Handle") local event = tool:WaitForChild("RemoteEvent") local uis = game:GetService("UserInputService") local canhit = true uis.InputBegan:Connect(function(Input,gameProcessed) if not gameProcessed then if Input.UserInputType == Enum.UserInputType.MouseButton1 and canhit then event:FireServer() canhit = false wait(10) canhit = true end end end)
Paste this code into your serverscript
Server Script:
local tool = script.Parent local handle = tool:WaitForChild("Handle") local event = handle:WaitForChild("RemoteEvent") local canhit = true local damaged = false event.OnServerEvent:Connect(function(player,arg1,arg2) if canhit then Handle.Touched:Connect(function(hit) local hum = hi.Parent:FindFirstChildOfClass("Humanoid") if hum and not damaged then hum:TakeDamage(40) damaged = true handle.Transparency = 1 end end) wait(10) damaged = false canhit = true handle.Transparency = 0 end end)