Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

my car spawner spawn mutiple cars help ?

Asked by 3 years ago
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)


0
try adding a debounce in the local script side of the remote event gamingwithjbthepro 76 — 3y
0
i dont know where to put it pokeybevermon -5 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

0
i dont know where to put it pokeybevermon -5 — 3y
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 mariohead13 129 — 3y
0
didnt work pokeybevermon -5 — 3y
0
can you show me your localscript? mariohead13 129 — 3y
Ad

Answer this question