Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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.

Ad

Answer this question