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

my car spawner spawn mutiple cars help ?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnCarEvent = ReplicatedStorage:WaitForChild("SpawnCar")
local DeleteCarEvent = ReplicatedStorage:WaitForChild("DeleteCar")

SpawnCarEvent.OnServerEvent:Connect(function(player, carName)
	local Car = ServerStorage:FindFirstChild("Cars"):FindFirstChild(carName)
	local CurCar = game.Workspace:FindFirstChild(player.Name .. 'sCar')
	if CurCar then
		CurCar:Remove()
	end
	if Car then
		local clonedCar = Car:Clone()
		clonedCar.Name = player.Name .. 'sCar'
		clonedCar.Parent = game.Workspace
		clonedCar:MoveTo(player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame.LookVector * 15)
	end
end)

DeleteCarEvent.OnServerEvent:Connect(function(player, Car)
	local Car = game.Workspace:FindFirstChild(player.Name .. 'sCar')
	if Car then
		Car:Remove()
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local Car = game.Workspace:FindFirstChild(player.Name .. 'sCar')
	if Car then
		Car:Remove()
	end
end)

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local Car = game.Workspace:FindFirstChild(player.Name .. 'sCar')
		if Car then
			Car:Remove()
		end
	end)
end)


2 comments

0

try adding a debounce in the local script side of the remote event

0

i dont know where to put it

1 answer

I think the answer is simple, try putting a delay in the localscript after you fire the remoteEvent.

4 comments

0

i dont know where to put it

0

You have a localscript that is firing the SpawnCarEvent remoteEvent, am I right? So, just after you fire it, use a debounce. Here is an example https://dpaste.org/pz8C

0

didnt work

0

can you show me your localscript?

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