Hello, I am making a Vehicle Spawner system but I am stuck in 2 things, The Spawner GUI and be cloned many times by clicking a box again, and that Vehicles would have the chance to spawn ontop of each other.
local GUI = Parent["Car Spawn"]
local function spawn(player)
local a = GUI:Clone()
a.Parent = player.PlayerGui
end
Parent.ClickDetector.MouseClick:Connect(spawn)
To solve the GUI a problem, you should make like a bool value to check if the player has the GUI or not. Secondly, to solve the car problem, just make them spawn next to each other.
You need to look if the vehicle is spawned already do
local vehiclespawned = false
while wait(1) do
if vehiclespawned == true then
print("Vehicle is already spawned ")
elseif vehiclespawned == false then
-- Spawn The Vehicle
end
end
you also need to set the
local vehiclespawned = false
set it to true if it get’s spawned
If you are making it with a button you need to do this
local vehiclespawned = false
local Button = script.Parent
Button.MouseButton1Click:Connect(function()
while wait(1) do
if vehiclespawned == true then
print("Vehicle is already spawned ")
elseif vehiclespawned == false then
vehiclespawned = true
-- Spawn The Vehicle
end
end
end)
set a part infront of the vehicle or arount it if the vehicle touched it there can spawn an other vehicle.
so you need to set the
local vehiclespawned = false
back to false and not true cause it will get true when a vehicle is spawned
so when the vehicle touched the part it will set it to false so that an other vehicle can spawn back again.
I just came up with an idea if you have the part around it and you have make in collide make it when a player touched it cause ye the player needs to be in the vehicle than it will set it back to false
so that will work fine but make sure to set a delay when a player did touch it so there are no vehicles spawning on top of each other
nothing cause the player did never touch the part so no vehicle can respawn again but u can create if the player did not touched the part after 30 seconds the vehicle will delete