I can't find out why this script is erroring

I’m just making a simple “Shop” like script, however, in the RemoteEvent arguments, it complains about:

attempt to compare number <= string

Code:

local players = game:GetService("Players")
local serverScriptService = game:GetService("ServerScriptService")

local buySlides = workspace:FindFirstChild("SlideBuy")
local replicatedStorage = game:GetService("ReplicatedStorage")

local events = replicatedStorage.Events

events.BuySlide.OnServerEvent:Connect(function(player,slideToBuy,price)
	if player["SlideData"][slideToBuy].Value == true then
		return
	end
	
	if slideToBuy == "Slide1" then
		return
	end
	
	if player.leaderstats.Points.Value >= price.Value then
		player.leaderstats.Points.Value -= price.Value
		
		player["SlideData"][slideToBuy].Value = true
		events.BuySlide:FireClient(player,slideToBuy)
	end
end)

Line 18 if player.leaderstats.Points.Value >= price.Value then

1 Like

Sounds like price.Value is a string instance not a number.
Try doing

if player.leaderstats.Points.Value >= tonumber(price.Value) then
2 Likes

Check the price value class name, if its a string value then that’s probably the problem

The value is probably a string value. It should be a number.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.