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

My shop GUI only works in studio but not in an actual sever, why not?

Asked by 8 years ago
local player = game.Players.LocalPlayer
local currency = player:WaitForChild('leaderstats').Coins
local amount = 200
local tool = game.ReplicatedStorage:WaitForChild('LinkedSword')
local indextext = script.Parent.Text
script.Parent.MouseButton1Click:connect(function()
    if currency.Value >= amount and not player.Backpack:FindFirstChild('LinkedSword') or player.Character:FindFirstChild('LinkedSword') then
        currency.Value = currency.Value - amount        
        local newtool = tool:Clone()
        newtool.Parent = player.Backpack
        script.Parent.TextColor3 = Color3.fromRGB(11, 199, 4)
        script.Parent.Text = 'Purchase succesful!'
        wait(2)
        script.Parent.TextColor3 = Color3.fromRGB(27, 42, 53)
        script.Parent.Text = indextext
    else
        script.Parent.TextColor3 = Color3.fromRGB(255, 0, 0)
        script.Parent.Text = 'Purchase failed, you either already have this item or do not have enough coins'
        wait(2)
        script.Parent.TextColor3 = Color3.fromRGB(27, 42, 53)
        script.Parent.Text = indextext
    end
end)

script.Parent.MouseEnter:connect(function()
    script.Parent.Parent.Parent.ProductImage.Image = 'rbxassetid://'..script.ImageValue.Value
    script.Parent.Parent.Parent.Description.Text = script.DescValue.Value
    script.Parent.Parent.Parent.ProductTitle.Text = script.TitleValue.Value
    script.Parent.Parent.Parent.SwordCost.Text = script.CostValue.Value
    script.Parent.Parent.Parent.SwordDamage.Text = script.DamageValue.Value
end)

script.Parent.MouseLeave:connect(function()
    script.Parent.Parent.Parent.ProductImage.Image = 'rbxassetid://'
    script.Parent.Parent.Parent.Description.Text = ''
    script.Parent.Parent.Parent.ProductTitle.Text = ''
    script.Parent.Parent.Parent.SwordCost.Text = ''
    script.Parent.Parent.Parent.SwordDamage.Text = ''
end)

3 answers

Log in to vote
0
Answered by 8 years ago

Is it a LocalScript? It should be a LocalScript.

0
Yes of course it is a local script... ThatOneKid7590 45 — 8y
0
Well is there any output (F9)? Is there anything else you can tell us at all? SwardGames 325 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

You have FE enabled. The client cannot change anything in the real server. Either disable FE(Not recommended) or use RemoteEvents to make the server do it(recommended).

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Try using WaitForChild(), it works in solo play but in server play, you need to wait for everything to lad first. For example, let's say you want your GUI's to load, simply do this:


game:WaitForChild("StarterGui") --the rest of your stuff.

Hope this helped.

Answer this question