Still have questions? Join our Discord server and get real time help.
0

# Making a Spawn limit (Cant spawn multiple vehicles?)

Asked by 8 months ago

So in this video of Alvin Blocks where he makes a car Shop gui (https://www.youtube.com/watch?v=zM6QhIn_JBY) But you can spawn multiple cars when you've bought it.

I have a script that should remove the old car after new one is spawned but i cant get it to work. Am i doing something wrong or i need to put the script somewhere else?

local theOldCar=workspace:FindFirstChild('CarName')
if theOldCar~=nil then theOldCar:Destroy()?


0
I think the question mark at the end on line 2 near :Destroy() is the reason. y3xr 0 — 8mo
0
Let the spawn script handle removing the old car model unsatisfie_d 1449 — 8mo
0
Post the script that spawns the car when a player purchases it unsatisfie_d 1449 — 8mo
0
Didnt work Vibesgus 17 — 8mo

0
Answered by 8 months ago
Edited 8 months ago

If you handle this well - then theOldCar variable should never be nil - you really shouldn't need to run that check. Aside from that - nothing here should be incorrect. If it is not working - I would prioritize checking the location of theOldCar, and be sure you're searching in the right spot.

0
Can you show me how the script should look like then? Vibesgus 17 — 8mo
0
Nothing which you posted is incorrect (given that the ? on the second line isn't actually in the code). This is classic debugging. Find out how far the script can work properly, and make amendments. You should give a look to where theOldCar is actually located, and be sure you're accessing the correct spot. SummerEquinox 623 — 8mo
0
Hmm cant get it to work.. The car model is in ServerStorage, But by spawning it the car spawns in workspace. Nothing shows up on the output.. Should i place the script somewhere else? Vibesgus 17 — 8mo
View all comments (8 more)
0
Alright, here's the fix - Alvin has decided to name the cars "Username's Car" rather than their actual names. So you need to search workspace for player.Name .. "'s" .. NameOfCar over NameOfCar. I have fixed it for you - each player can only spawn one of each car type. Uncopylocked Fixed Place: https://www.roblox.com/games/2474124452/Car-Spawn-Fix-for-scriptinghelpers SummerEquinox 623 — 8mo
0
Yeah that's what i thought at school today. Thanks so much tho, I was testing different scripts to get it fixed and nothing worked, I was so confused and thought ill give up. Seriously you saved my game and lot of time for me. Thank you!                                                      Also do the cars stay in the game when you leave? If so i need a way to remove that.   Vibesgus 17 — 8mo
0
You can just run a function that destroy's that user's cars when they leave. Also, if the issue is fixed be sure to accept the solution. SummerEquinox 623 — 8mo
0
How do you run that function? Vibesgus 17 — 8mo
0
When a player leaves, just scan workspace for any of these four cars attached to your username. SummerEquinox 623 — 8mo
0
i dont know how to do that.. Can you show me? Vibesgus 17 — 8mo
0
By the way is it possible to spawn only 1 from all types not 3 at a time? Vibesgus 17 — 8mo
0
Yes - this is possible, but as stated scriptinghelpers is not a request site. If you can't do any of the work then it immediately becomes request-esk. Some of these things you will need to figure out a bit, and then ask for help. SummerEquinox 623 — 8mo