Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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)

0
I see that it says 'buy brick'. Is this referring to a GUI or a physical brick? Shawnyg 4330 — 10y
0
Can you tell me what line you see it on? Champion121212 22 — 10y
0
BuyButton is a surface GUI on a brick Champion121212 22 — 10y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Replace line 28 with

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

Answer this question