Hey,
I am beginning to despair... as I am getting nowhere. I have a car spawner but players can spawn an infinite number of cars at once and when players leave the game the car remains there. and i can't manage to make a delete button for the cars .-.
now my question:
how do I make it so that player can spawn only 1 car, but if it then deletes the car it can spawn 1 again?
how do I make it that the car automatically despawns when the player leavs from the game?
How do I make a delete button for the current car he owns?
sry for the many questions but I've been trying for 1 month to do this.
Here is my car spawner script:
local rep = game:GetService("ReplicatedStorage")
local event = rep:FindFirstChild("VWPassat")
script.Parent.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer
event:FireServer(plr)
end)
local rep = game:GetService("ReplicatedStorage")
local event = rep:FindFirstChild("VWPassat") --your RemoteEvent
local function CreateCar(plr)
if plr.TeamColor == BrickColor.new("Really blue")-- your team color
then
local clone = game.ServerStorage:WaitForChild("VWPassat"):Clone()
clone.Parent = game.Workspace
clone:MakeJoints()
else print("Not on the correct team")-- if you want an error message or something do it here
end
end
event.OnServerEvent:Connect(CreateCar)
~VeoBlack (ExperienceHP)

3 comments
Thank you very much! it worked :D a small question still, since I just have only 1 vehicle what I can spawn, how is it with if I also have other vehicles? is then the current car deleted and spawned for the new? oh yes this line code "if plr.TeamColor == BrickColor.new("Really blue") -- your team color then local clone2 is there so that only this group can access or spawn ^^
You would have to user PlayerAdded event which fires when you join the game, then you would create empty table of player's cars and store all of them there, here is example https://pastebin.com/TXLhG1nV. In this case when you are firing remote event to Create/Destroy the car you need to specify the second parameter which is the brand of the car, so you can have multiple of them, "Yellow", "Blue"..
Hey, ok thanks, only I didn't understand it correctly, where do I have to insert that? (can we write about Discord? its better ^^ if the answer is yes here my username: VeoBlack#9999