My RemoteEvent doesn't want to check if my coins.Value is equal to or above 50

Hey, I’m trying to make a shop system which for some reason just thinks I’m poor, and honestly It’d be easier to explain if I just show the script:

local RS = game:GetService("ReplicatedStorage")

local stop = RS["stop sign"]

RS.Remotes.RemoteEvent.OnServerEvent:connect(function(player)
	print("yes")
	local coins = player:WaitForChild("leaderstats").Coins
	if coins.Value >= 50 then
		print("rich men")
		stop:Clone().Parent = player:WaitForChild("Backpack")
	else
		print("poor men")
	end
end)

It keeps printing ‘poor men’ even though my coin value is 50. Everything is spelt correctly, I think. Any support would be appreciated.

try

local RS = game:GetService("ReplicatedStorage")

local stop = RS["stop sign"]

RS.Remotes.RemoteEvent.OnServerEvent:connect(function(player)
	print("yes")
	local coins = player.leaderstats.Coins
	if coins.Value >= 50 then
		print("rich men")
		stop:Clone().Parent = player:WaitForChild("Backpack")
	else
		print("poor men")
	end
end)

It still thinks I’m a poor men ):

show explorer for leaderstats and coins

Can you show the local script?

leaderstat

It prints fired like I want it to:

local RS = game:GetService("ReplicatedStorage")

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	RS.Remotes.RemoteEvent:FireServer()
	print("Fired")
end)```

are you sure that coin instance is an intvalue?

Yeah I’m sure it is an IntValue

Make sure to change leaderstats coins value on the server using a remote event or else the server see that the value is unchanged.

1 Like

What is:

stop:Clone().Parent = player:WaitForChild("Backpack")

supposed to do?

But I changed the value on the server anyway, so why would I need a remote event?

It clones the stopsign into the backpack

Why would you need to do that?

When someone buys an item from the shop, it would clone the item into their backpack

how are you setting the Coins Value?

Every minute you get 5 coins, I do it in the server.

manually set the Coins Value in the explorer then try buy it

Ohh thats what you meant. I do that anyway, it doesn’t work.

local RS = game:GetService("ReplicatedStorage")

local stop = RS["stop sign"]

RS.Remotes.RemoteEvent.OnServerEvent:connect(function(player)
	print("Fired")
	local coins = player.leaderstats.Coins
    print("Coins =", coins.Value)
	if coins.Value >= 50 then
		print("yep,")
		stop:Clone().Parent = player:WaitForChild("Backpack")
	else
		print("nope")
	end
end)

try this and show output wait one second there try that