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
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