Hi!
I want my Tool to restore health to the player holding it when he clicks the left mouse button.
The problem is that it sets it back to what it was before after restoring health to the player. How do I prevent that?
Here is the code in my LocalScript (the parent is Tool):
script.Parent.Activated:connect(function() local player = game.Players.LocalPlayer local character = player.Character local hum = character.Humanoid if hum ~= nil then hum.Health = hum.Health + 20 end end)
This is due to FE (Filtering Enabled). You would need to fire the server since that is from client-sided. I recommend you to look at some articles about filtering enabled.
But you would need to fire the server, and here is how you do this
--Server local remote = pathToRemote remote.OnServerEvent:Connect(function(plr, amount) if plr.Character.Humanoid then plr.Character.Humanoid = plr.Character.Humanoid + amount end end)
--Client local remote = pathToRemote script.Parent.Activated:connect(function() local player = game.Players.LocalPlayer local character = player.Character local hum = character.Humanoid if hum ~= nil then remote:FireServer(20) end end)