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)
4 comments
fix ur lua tags
can you reformat your question?
https://forum.scriptinghelpers.org/topic/82/how-to-format-questions-answers-on-the-main-site
well after hit or damage, either put Handle.Transparency = 0 or Handle:Destroy()