Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I have a few issues on my car spawn button. Help please? [UNANSWERED]

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:

  1. The cars do not spawn at the positions that I put in the script
  2. I assume the intvalue doesn't seem to work because I am still able to buy both cars
  3. How do I make it so people cant spawn cars on top of eachother?
  4. 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

0

I see that it says 'buy brick'. Is this referring to a GUI or a physical brick?

0

Can you tell me what line you see it on?

0

BuyButton is a surface GUI on a brick

1 answer

✓ Accepted answer

Replace line 28 with

clo:MoveTo(Vector3.new(0,5,0))

This discussion is preserved as it was. New answers, comments, and votes are closed.