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

The buttons in my SurfaceGUI shop don't work?

Asked by
ExcelUp 24
7 years ago

I have a game where the points in the leaderboard are 'Wins' for winning a round of the game. The Wins Value is found in Players > LocalPlayer > leaderstats > Wins. I have a shop, that is scripted onto a SurfaceGUI, where if you click the Bloxy Cola text button, it should clone the gear called 'BloxyCola' from the ReplicatedStorage in a Model called 'Gears' into the player's backpack, if they have 3 wins. However, when I click the button nothing happens. The code is in a LocalScript, and I have tried a normal script aswell, but still nothing works. The LocalScript is found in:

game.Workspace.Shop.ShopGUI.MainFrame.ItemFrame.BloxyColaButton.LocalScipt 

where 'Shop' is a part, 'ShopGUI' is a SurfaceGUI, 'MainFrame' and 'ItemFrame' are frames, and 'BloxyColaButton' is a text button. Can someone please help me?

local player = game.Players.LocalPlayer
local wins = player:WaitForChild("leaderstats").Wins

script.Parent.MouseButton1Click:connect(function()
    if wins.Value >= 3 then
        game.ReplicatedStorage.Gears.BloxyCola:Clone().Parent = player.Backpack
    end
end)
0
I am pretty sure there may be something wrong with the script that puts the tool into the backpack of the player. I may be wrong but thats what im guessing. Anyways good question to ask. Glassify 15 — 7y

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

As you're doing it now, you're putting a localscript inside the workspace. That doesn't work.

Solution

Put your SurfaceGui inside the Player.PlayerGui (Or StarterGui by default) and set its Adornee property to the part you want it shown on.

0
Hm, it still doesn't work. I moved the SurfaceGUI into the StarterGUI, and set the adronee to the Shop part, and it still doesn't work. If you could help me investigate the problem, I would be very grateful, but in the meantime I will try take a look at any more possible errors. ExcelUp 24 — 7y
0
Nevermind, I forgot to close a parenthesis at the end of function, while editing it earlier on. Thank you so much for your help! ExcelUp 24 — 7y
Ad

Answer this question