So I created a car store where people can spawn cars from it if they have enough money. I used an intvalue to check if they have a car or not. 0 = no car and 1 = car. I have the following issues with it:
- The cars do not spawn at the positions that I put in the script
- I assume the intvalue doesn't seem to work because I am still able to buy both cars
- How do I make it so people cant spawn cars on top of eachother?
- How do I make this a loop, after you click the button once, you have to die before you can buy another car. Note: This is a localscript inside the player. It currently does spawn the car from lighting in the position it was before I put it in lighting. And it does take away money apon purchase.
-- setup local variables
local buyButton1 = game.Workspace.BuyButton1.SurfaceGui.TextButton
local amount = 1000
local carname = game.Lighting.Godzilla
-- when player clicks on buy brick promt him/her to buy a product
buyButton1.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,5,0) -- Where you want it to be spawned.
game.Players.LocalPlayer.CarOwner.Value = 1
end
end)
-- setup local variables
local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton
local amount = 500
local carname = game.Lighting.Blueberry
-- 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,5,0) -- Where you want it to be spawned.
game.Players.LocalPlayer.CarOwner.Value = 1
end
end)

4 comments
You can test it here. http://www.roblox.com/Script-Testing-place?id=137105154
I see that it says 'buy brick'. Is this referring to a GUI or a physical brick?
Can you tell me what line you see it on?
BuyButton is a surface GUI on a brick