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

Team not changing when player has enough points?

So, when I go click a button it gives me a error saying "attempt to compare number with userdata". What I am trying to do is check if a player has 50 or above points then take 50 points from them and make them host. Here is my code:

script.Parent.MouseButton1Click:connect(function()
    if game.Players.LocalPlayer.leaderstats.Points >= 50 then
        game.Players.LocalPlayer.leaderstats.Points = game.Players.LocalPlayer.leaderstats.Points - 50
        game.Players.LocalPlayer.TeamColor = BrickColor.new("New Yeller")
        game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(14.03, 13.952, -6.602)
    end
end)

1 comment

0

say white power and then it will work

1 answer

I think it’s because you forgot to put .Value on every line that has game.Players.LocalPlayer.leaderstats.Points You’re using the value object itself, not the value.

So just change all the lines with game.Players.LocalPlayer.leaderstats.Points into game.Players.LocalPlayer.leaderstats.Points.Value.

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