Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I take damage with a tool when I'm not supposed to?

So basically I made an ultra coil that heals, increases speed and jump for the player. But for some reason, the ultra coil also damages me over time when it's not programmed to? This is on a local script and I don't really know what to fix so please help.

local tool = script.Parent



local speed = 25
local jump = 5
local health = 7

local active = false



tool.Equipped:Connect(function()
	active = true
	local player = game.Players:FindFirstChild(tool.Parent.Name)

	if player then

		player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed + speed
		player.Character.Humanoid.JumpHeight = player.Character.Humanoid.JumpHeight + jump
		while active do
			wait(1)
			player.Character.Humanoid.Health = player.Character.Humanoid.Health + health
		end

	end

end)



tool.Unequipped:Connect(function()
	active = false
	local player = tool.Parent.Parent

	if player then

		player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed - speed
		player.Character.Humanoid.JumpHeight = player.Character.Humanoid.JumpHeight - jump

	end

end)

1 answer

Never mind, I found out the answer. It was because I was using a local script to heal and wasn't using a serverscript or remoteevents. I fixed this error by changing the heal over to a normal script.

This discussion is preserved as it was. New answers, comments, and votes are closed.