So, I'm trying to make a gun shop gui on my game and it doesn't work and the output doesn't say anything and idk what to do... (It's in a local script)
function BuyGun() local Clicked = game.Players.LocalPlayer local Player = game.Players:WaitForChild(Clicked) if Player.leaderstats.Points.Value >= 10 then Player.leaderstats.Points.Value = Player.leaderstats.Points.Value - 10 local Gun = game.ServerStorage.Pistol:Clone() Gun.Parent = Player.Backpack end end script.Parent.MouseButton1Click:connect(BuyGun)
You tried to get the Player using FindFirstChild() incorrectly. You also had no need to use it like that. When you use it, you need to use a string of the objects name you're getting.
function BuyGun() local Player = game.Players.LocalPlayer if Player.leaderstats.Points.Value >= 10 then Player.leaderstats.Points.Value = Player.leaderstats.Points.Value - 10 local Gun = game.ServerStorage.Pistol:Clone() Gun.Parent = Player.Backpack end end script.Parent.MouseButton1Click:connect(BuyGun)
Try it now
Anyways, hope this helped, if you have any further questions/problems, please leave a comment below :P