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

Attempt to comapare userdata with a number?

PointsService = game:GetService("PointsService")
Stat = "KOs" 
game.Players.PlayerAdded:connect(function(p)
        repeat wait() until p:FindFirstChild("leaderstats") ~= nil
        repeat wait() until p.leaderstats:FindFirstChild(Stat) ~= nil
		repeat wait() until p:FindFirstChild("Need") ~= nil
        p.leaderstats[Stat].Changed:connect(function(prop)
                print("Value changed!")
				local need = p:FindFirstChild("Need")
				print("Found Need")
                if prop >= need then
                        game:GetService("PointsService"):AwardPoints(p.userId,1)
need = need + 5
print("Awarded points and need has went up")
                end
        end)
end)

Line 11, (if prop >= need then) is bugged. I don't know why it won't find the value of it.

1 answer

That because it is userdata. You are defining need as

local need = p:FindFirstChild("Need")

And you can't compare it to a number, I think you wanted to defined it as follow

local need = p:FindFirstChild("Need").Value

5 comments

0

I need to specify the Value? :/ Lol. If I did really mess up that much i'm going to cry. ):

0

I'm guessing Need is a NumberValue, you got a reference to the Instance, which is userdata. You need to access its property Value to actually get the stored value.

0

Yeah, I know. But when I was coding it, I looked at 'prop' and if you look, it doesn't get the value like that, so I imagined for some odd reason that it was 100% fine.

0

Also, it still doesn't work. It provides a player point when they get a kill. :/

0

At least is not an error anymore

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