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

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

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.

4 comments

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.

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

0

also you need to have a code, we cant just give you a script but we can help with a current one

0

Thanks for the information, I made the script and it works good.

1 answer

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

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