function Freedom() local RS = game:GetService("ReplicatedStorage") local ship = RS:WaitForChild("Freedom") local spawner = game.Workspace.Freedomspawn local player = game.Players.LocalPlayer local button = script.Parent local price = 1000000 local stats = game.Players.LocalPlayer:WaitForChild("leaderstats") if stats.Cash.Value >= price then stats.Cash.Value = stats.Cash.Value - price local cloned = ship:Clone() cloned.Parent = workspace cloned.CFrame = cloned.CFrame + (0,0,5) end end end button.MouseButton1Click:connect(Freedom)
NOTE | Almost everytime you use an if then statement you need to use else or elseif to let the game know... 'Okay, so if this doesn't work I would do this'
--Instructions to following script:
RS = game:GetService("ReplicatedStorage") ship = game.ServerStorage.Ship spawner = game.Workspace.Spawn plr = game.Players.LocalPlayer button = script.Parent price = 1000000 stats = game.Players.LocalPlayer.leaderstats.Cash script.Parent.MouseButton1Click:Connect(function(onClick) if Cash.Value >= price then Cash.Value = Cash.Value - price ship:Clone().Parent = game.Workspace elseif Cash.Value <= price then Cash.Value = Cash.Value - 0 plr.Character.Humanoid.Health = plr.Character.Humanoid.Health - 10 --Optional end end)