I am trying to make a surface GUI which spawns you a car in. I also need it to deduct money from the player's leaderstat. It worked before i added the money system and now when i do have the money system doesn't work Code: (in a script)
local clone = game.ReplicatedStorage.Trodent610
backup = clone:Clone()
function click(player)
local stats = player:FindFirstChild('leaderstats')
if not stats then return end
local Money = stats:FindFirstChild('Money')
if not Money then return end
if Money.Value >= 100 then
script.Parent.Text="Your car is spawning!"
script.Parent.Visible = false
clone=backup:clone()
clone.Parent=game.Workspace
clone:makeJoints()
Money.Value = Money.Value - 100
wait(10)
script.Parent.Text="Trodent 610"
script.Parent.Visible = true
end
end
script.Parent.MouseButton1Click:Connect(click)
This is the error it brings up: Workspace.spawnst.SurfaceGui.trodent.Script:4: attempt to index local 'player' (a nil value)

3 comments
Alright, ill try that out!
Unfortunately, it did not work.
Keep in mind, the scripts are in a TextLabel and its a SurfaceGUI