Healing Tool Does Heal Me as Intended But Keeps Reverting My HP To its Original Value

I want to make a stim kind of tool which is supposed to regenerate your hp by 35% and if your hp is above 90% it would display a gui that has text (for now its gonna print out a message, im still working on it) but when used it would regenerate your hp as intended but after a second it reverts it into its original hp value, i thought it was with the Tool:Destroy() line so i changed it so that it parents it to ReplicatedStorage but that didnt work, pls help.

local Autoinjector = script.Parent
local player = game.Players.LocalPlayer
local Humanoid = player.Character and player.Character:FindFirstChild("Humanoid")

function onActivation()
	if Humanoid and Humanoid.Health <= 90 then
		wait(2)
		Humanoid.Health = Humanoid.Health + 35 -- This might change in the future
		Autoinjector:Destroy()
		else print("IM NOT THAT STUPID! IM FINE WHY WOULD I GIVE THIS TO MYSELF?") -- Eventually Ill Replace This With A GUI Which Says A Bunch Of Phrases Warning The Player Of Its Side Effects.
	end
end

Autoinjector.Activated:Connect(onActivation)
2 Likes

The script is running locally, the health change will be quickly overrided by what the server sees. Change the script into a server sided one

1 Like