I am trying to make a button that under the conditions that someone doesn't own a car and has enough money, they can clone a car from Lighting and put it at a certain position in Workspace. And then make it so the car owner can't buy anymore cars. Please excuse my Lua as it is complete and utter trash.
What I did was made it so if a player does not own a car their intvalue is 0 and if they do the intvalue is 1. I wasn't sure of a better way to have it. If someone knows a better way I can do it so the game recognizes the car to be owned by a player, please share it! Thanks.
-- setup local variables local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton local amount = 500 local carname = game.Lighting.Godzilla -- when player clicks on buy brick promt him/her to buy a product buyButton.MouseButton1Click:connect(function() if game.Players.LocalPlayer.CarOwner.Value == 0 and if game.Players.LocalPlayer.leaderstats.Money.Value >= amount then game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - amount carname:clone() carname.clone.Parent = game.Workspace carname.clone.Position = (0,0,0) game.Players.LocalPlayer.CarOwner.Value = 1 else end end)
I'd recommend setting a variable for the clone, which I did. The way you have it set up with the IntValue is fine. I fixed a few minor issues.
-- setup local variables local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton local amount = 500 local carname = game.Lighting.Godzilla -- when player clicks on buy brick promt him/her to buy a product buyButton.MouseButton1Click:connect(function() if (game.Players.LocalPlayer.CarOwner.Value == 0) and (game.Players.LocalPlayer.leaderstats.Money.Value >= amount) then game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - amount clo = carname:clone() clo.Parent = game.Workspace clo:MakeJoints() clo:MoveTo(0,0,0) -- Where you want it to be spawned. game.Players.LocalPlayer.CarOwner.Value = 1 end end)