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

Why isn't the condition for my webhook script not working?

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"

2 comments

0

you gotta write plr.Points.Value in the if statement

0

also you can't use "[My webhook]" you gotaa use a real webhook

1 answer

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)

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