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)

3 comments
Also, the part position doesn't work, it just spawns where the model was before it was put in lighting.
I have 2 more things, the part seems to break in pieces then welds.. http://puu.sh/ablnj/98a6348e80.jpg and also how do I make it so the script doesn't break after it is used one time...? I will accept the answer once I get it working how I need it. :)
The car only breaks if it was Cframed and has a weld script in it, uncframed cars are fine.