Basically, I made a gui that when you press a button a car appears. I want a way so you only have one car at a time. I figured I could tag the cars by putting a StringValue.
That's as far as I went but I really need help on this, been troubling me for a few days.
Your problem can be solved using a dictionary. The script checks if there already is a car that has been spawned by the player, and if there is a car, it deletes the old car and spawns the new one.
local spawnedCars = {}; function spawnCar (player, car) local oldCar = spawnedCars[player.UserId]; if oldCar then spawnedCars[player.UserId]:Destroy(); spawnedCars[player.UserId] = nil; end spawnedCars[player.UserId] = car; end
Closed as Not Constructive by IcyEvil, User#21908, 1TheNoobestNoob, User#19524, User#20388, green271, and DeceptiveCaster
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?