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

'attempt to compare string and number'. How to fix?

Asked by 3 years ago

Here is my code. It is meant to work as a checkpoint system.

local checkpoint = script.Parent

checkpoint.Touched:Connect(function(otherPart)
    local partParent = otherPart.Parent
    local hum = partParent:FindFirstChildWhichIsA('Humanoid')
    if hum then
        local plrName = partParent.Name
        local plr = game.Players[plrName]
        local stage = checkpoint.Name
        if plr.leaderstats.Stage.Value >= stage then
        else
            plr.leaderstats.StageValue = stage
        end
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago
local stage = tonumber(checkpoint.Name)

Ad

Answer this question