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)
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.