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

Shop script outputting always not that what I want at "<=", why?

Hello guys, I have a weird problem: I am trying to make a click detector shop. This is the full script:

local tool = game.ServerStorage.Pistol
local klone = tool:clone()
script.Parent.ClickDetector.MouseClick:connect(function(plr)
local Goldvalue = plr.leaderstats.Gold.Value
if Goldvalue >= 10000 then
	Goldvalue = Goldvalue - 10000
	if klone.Parent ~= plr.Backpack then
	 klone.Parent = plr.Backpack
	 else
	 print("Your backpack is full")
	end
else
print("Not enough money")
end
end)

The important thing here is this:

if Goldvalue >= 10000 then

Because if I set it like this (>=) then if I have 0 Gold it says Not enough money. If I have 10000 Gold it saysNot enough money and with over 10000 Gold it says also Not enough money

if Goldvalue <= 10000 then

When I rotate the symbol and I have 0 Gold it works. If I have 10000 Gold it works and with over 10000 Gold it works also. I don't understand why.

My problem problem now is that I don't get a wheapon when I have 10000 Gold or above. Does anyone know why it is so weird? Some Info: -Gold is a Intvalue -The script is a serverscript -The leaderboard works correctly -I tried to divide the <= and <= and == with if ... or ... then and elseif

5 comments

0

Change "connect" to "Connect", prefer using plr.leaderstats.Gold and then Goldvalue.Value.

0

the c on line 2 in "clone()" is supposed to bee "Clone()" that might be why.

0

ok, thanks! I try

0

It did not work, I tried to put before the if statement of goldvalue "print(Goldvalue)" and it said always 0, I think there I have a problem

0

My problem is that it is saying always Goldvalue = 0

1 answer

✓ Accepted answer

Your Code should be like this

local tool = game.ServerStorage.Pistol
local klone = tool:Clone()
script.Parent.ClickDetector.MouseClick:connect(function(plr)
local Goldvalue = plr.leaderstats.Gold.Value
if Goldvalue >= 10000 then
    Goldvalue = Goldvalue - 10000
    if klone.Parent ~= plr.Backpack then
     klone.Parent = plr.Backpack
else
print("Not enough money")
end
end)

tbh I don't think you can have 2 else in one Script without ending the whole thing

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