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

Shop GUI i created only works perfectly fine in studio but doesn't work when i play the actual game?

Asked by 7 years ago
local player = game.Players.LocalPlayer
local currency = player:WaitForChild('leaderstats').Coins
local amount = 200
local tool = game.ServerStorage: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)

I don't get why it doesn't work in an actual server. Anyone know why?

1 answer

Log in to vote
0
Answered by 7 years ago

I'm guessing this is a local script? Just a guess, but use Lighting or ReplicatedStorage instead of ServerStorage for your sword. Also, IS it "Clone" or "clone" -- I'm really sleepy right now so I'm not very sure

0
It's both, although Clone is preferred. SwardGames 325 — 7y
Ad

Answer this question