I am making a script that sends information to a discord server when a player has reached a certain amount of points. Everything is working but the condition.
game.Players.PlayerAdded:Connect(function(plr) local points = Instance.new("NumberValue",plr) points.Name = "Points" points.Value = 0 local url = "[My webhook]" local http = game:GetService("HttpService") if plr.Points >= 7.5 then local Data = { ['content'] = plr.Name.." Passed!" } Data = http:JSONEncode(Data) http:PostAsync(url, Data) end end)
It keeps saying "attempt to compare number with userdata"
You referenced the points object and not it's value.
game.Players.PlayerAdded:Connect(function(plr) local points = Instance.new("NumberValue",plr) points.Name = "Points" points.Value = 0 local url = "[My webhook]" local http = game:GetService("HttpService") if plr.Points.Value >= 7.5 then -- now it references the value of points local Data = { ['content'] = plr.Name.." Passed!" } Data = http:JSONEncode(Data) http:PostAsync(url, Data) end end)