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

GuiSell thinks i always have 0 Ore, help?

Asked by 4 years ago

for some reason this always runs the elseif unless i have 0 ore. can anyone see my problem?

wait(0.1)
function sellclick()
    local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
    local item = plr.leaderboard.Ore
    local money = plr.leaderboard.Money
    local char = game.Workspace:FindFirstChild(plr.Name)

    if item.Value >= script.Parent.Amount.Value then
        item.Value = item.Value - script.Parent.Amount.Value
        money.MoneyAdd.Value = money.MoneyAdd.Value + script.Parent.Total.Value
        script.Parent.Parent.Parent.Approved.Visible = true
        wait(1.5)
        char.ShopTing.Value = 0
        script.Parent.Parent.Parent.Parent:Destroy()
    else if item.Value < script.Parent.Amount.Value then
        script.Parent.Parent.Parent.Denied.Visible = true
        wait(1.5)
        char.ShopTing.Value = 0
        script.Parent.Parent.Parent.Parent:Destroy()
    end
    end
end

script.Parent.Sell.MouseButton1Click:Connect(sellclick)

2 answers

Log in to vote
0
Answered by 4 years ago

I think the cause of your problem is that you are using a localscript. Change every script to Normal Scripts and then that will solve your issue. You also need to use Normal Script to Add ores or remove ores from your player.

0
Thank you! I was not using a local script, but I found another place where I was using one, which fixed it completely! DemonsEmperor 26 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

If you're changing your ore value from properties in studio while in run-time the client knows the value has updated but the server does not (use Test tab ->Current:Client/Server button to see what I mean)

I think you can use remote events or script.Parent.Amount.Changed to tell the script to update its variables :)

Answer this question