Basically I'm making a prestiging script, and my Level Value is a StringValue, it's saying that "attempt to compare number with string" How do I fix this? And what can I do to prevent this from happening again?

local plr = game.Players.LocalPlayer

local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.RemoteFolder:WaitForChild("Prestige")
local frame = script.Parent.Parent.Parent.PrestigeStepTwo
local current = script.Parent.Parent.Parent.Prestige
local intval = plr.leaderstats.Level

script.Parent.Accept.MouseButton1Down:Connect(function()
	if intval.Value >= 10 then
		remote:FireServer()
	end
end)

script.Parent.Decline.MouseButton1Down:Connect(function()
	frame.Visible = false
	current.Visible = true
end)

The error is on line 10.

5 comments

0

if the Level is a stringvalue just do tonumber(intval.Value) to convert a string to a number

0

Ohhh thank you!

0

Why store a level in a StringValue at all? There is an IntValue object. Is this for backwards-compatibility with some ancient leaderboard thing? I thought leaderboardstats could handle IntValue now.

0

I was wondering the same thing haha but anyway I really appreciate greatneil sharing tonumber, never knew it existed.

0

So, @EmilyBendsSpace I'm using a string value because when someone decides to prestige, their Level changed to "I -1" (roman numbers followed by their level)