Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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

0
Change "connect" to "Connect", prefer using plr.leaderstats.Gold and then Goldvalue.Value. Worthfall 2 — 4y
0
the c on line 2 in "clone()" is supposed to bee "Clone()" that might be why. ScriptToon 70 — 4y
0
ok, thanks! I try DieStockEnte 11 — 4y
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 DieStockEnte 11 — 4y
0
My problem is that it is saying always Goldvalue = 0 DieStockEnte 11 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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

Ad

Answer this question