Code:
local Cost = script.Parent.Cost
game.Players.PlayerAdded:Connect(function(plr)
local BuyGUI = plr.PlayerGui:FindFirstChild("BuyGUI")
if BuyGUI then
BuyGUI.BuyFrame.Yes.MouseButton1Click:Connect(function()
if plr.leaderstats.Cash.Value >= Cost then
plr.leaderstats.Cash.Value -= Cost
print("purchase successful")
end
end)
end
end)
There's no error, btw it's a normal Script

2 comments
What is it you are trying to achieve?
Try wait(10) to make sure the player has fully loaded. If that worked, you can use plr.CharacterAppearanceLoaded:Connect(function()) or something like thiat.