Hello. I am trying to give a player a certain item when they reach a leaderstat int value. Here is the
script. It’s a local script in a GUI in startguis. The player is grabbing the local player of the game. In the leaderstats, I have one thousand. It should give me the level give clearance. I know the events are working because I was messing with that earlier. Is it not grabbing the values?
while true do
local clearance = 0
if plr.leaderstats.XP.Value == NumberRange.new(0,9) then
clearance = 1
eventClearance:FireServer(clearance)
elseif plr.leaderstats.XP.Value == NumberRange.new(400,5000) then
clearance = 5
eventClearance:FireServer(clearance)
end
wait(5)
end
I don’t think you can compare a number to a NumberRange. They are two completely different data types. Second, for something like XP, it should be done on the server, not on the client, obviously for security reasons. Finally, you should only check the experience when the value of the XP changes, and not constantly every 5 seconds.
local clearance = 0
if plr.leaderstats.XP.Value >= 0 and plr.leaderstats.XP.Value <= 9 then
clearance = 1
eventClearance:FireServer(clearance)
elseif plr.leaderstats.XP.Value >= 400 and plr.leaderstats.XP.Value <= 5000 then
clearance = 5
eventClearance:FireServer(clearance)
end