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

Is there a way to have one car spawned in at a time for each player?

Asked by 4 years ago

I have an "Online Car Dealership" pretty much you are able to buy cars on a GUI in StarterGui and I want to have the player have only one car spawned at a time, so if he spawns in a new car, his old car will be deleted/destroyed.

I don't have any code because I am stumped on how to attempt this.

1
You need to store a reference to the current car a user has spawned. Either in a script, or a physical value, doesn't matter. Once they spawn a new one, destroy the current car, and set the new car to your reference variable. climethestair 1663 — 4y
0
When the player bought a car, you can change the model name to (player.Name.." Car's"). And when you click to spawn a car, the game will check if have a car with plr name in workspace, if find the car then destroy current, and spawn new car 174gb 290 — 4y
0
also you need to have a code, we cant just give you a script but we can help with a current one Gameplayer365247v2 1055 — 4y
0
Thanks for the information, I made the script and it works good. Skyxtlz 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

it is very simple. just like tools, when it is equipped, it put weapon on your hands, when you select another tool, the previous tool is gone, the new tool shown up. of course, you need to do destroy() in unequip event.

so now, back to your car. each car is a tool in your backpack, except, when you equip one tool, instead of weld a weapon into your hand. you spawn a car right in front of your torso position.

now,dont forget to implement unequip event, you need to destroy the car. before, another equip event is called.

so no matter you press 1, 2 3, 4, 5, or use mouse buttons, you only have one car in front of you

Ad

Answer this question