I'm trying to make a tool that has to be charged first before being able to damage.
Client:
local tool = script.Parent
local remoteEvent = tool.RemoteEvent
local charged = false
local canDamage = false
tool.Activated:Connect(function()
if not charged then
charged = true
end
end)
tool.Deactivated:Connect(function()
if charged then
remoteEvent:FireServer(charged)
wait(1)
charged = false
end
end)
Server:
local tool = script.Parent
local remoteEvent = tool.RemoteEvent
local blade = tool.Blade
remoteEvent.OnServerEvent:Connect(function(player, command)
if command then
blade.Touched:Connect(function(hit)
local humanoid = hit.Parent:WaitForChild("Humanoid")
humanoid:TakeDamage(100)
end)
end
end)
What it does is, it still damages even way after charged has been set to false. And we don't want that. I need it to only damage when it's only charged.
