Attempt to compare Instance <= number

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to make a shop using seconds in the game

  2. What is the issue? Include screenshots / videos if possible!
    The issue is when i try buying stuff it says attempt to compare Instance <= number

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to replace the price value with just the number, still nothing, ive placed the price from one place to other, still nothing.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

ServerScriptService:

game.ReplicatedStorage.Buy.OnServerEvent:Connect(function(player, price, item)
	if player.leaderstats.Seconds.Value >= price then
		player.leaderstats.Seconds.Value = player.leaderstats.Seconds.Value - price
		local clone = game.ServerStorage.Tools:FindFirstChild(item):Clone()
		clone.Parent = player.Backpack
	else
		error("Couldnt buy item")
	end
end)

LocalScript:

local player = game.Players.LocalPlayer
local item = "Slurpee"
local price = 150
local debounce = false

script.Parent.MouseButton1Click:Connect(function()
	if player.leaderstats.Seconds.Value >= price then
		if debounce == false then
			debounce = true
			script.Parent.Click:Play()
			game.ReplicatedStorage.Buy:FireServer(player, price, item)
			wait(2)
			debounce = false
		end
	else
		script.Parent.Error:Play()
	end
end)

There is no <= in your scripts. Can you screenshot the output?


im not even sure how it pulls out the “<=” even tho i have “>=”

game.ReplicatedStorage.Buy:FireServer(price, item)

Try this line instead, on the client. You don’t need to send the player variable to the server.

The error you are getting tells you the problem:

attempt to compare Instance <= number

You are trying to compare an Instance with a Number.

An Instance is an object, a Number is a value.

worked pretty well, i must say. i dont know why i even tried using player in the first place

1 Like

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