Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The buttons in my SurfaceGUI shop don't work?

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)

1 comment

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.

1 answer

✓ Accepted answer

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.

2 comments

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.

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.