Hello, for some reason my regen script works in studio, but in client it duplicates the car.
model = game.Workspace.Exceed – Change “Compressor” to the name of your model.
new = model:clone()
enabled = true
game.ReplicatedStorage.ExceedRemotes.RegenExceed.OnServerEvent:Connect(function()
if enabled then
script.Parent[“Car Ignition Startup”]:Play()
enabled = false
model:remove()
wait(0.3) – This is how long it will take to regen
model = new:clone()
model.Parent = game.Workspace
model:MakeJoints()
wait(5) – This is how long it will take for the regen button to be enabled after being used
enabled = true
end
end)
Unsure of what is causing this issue, to properly fix it I think I’d need to do debugging and testing inside of studio, however I can advise that you try :Destroy() rather than :Remove(), and see if that helps. Simply because I believe remove is deprecated.
You need a longer wait. And if the car is still there it will cause issues. Before cloning the car you need to make sure the area is clear. An easy solution would be creating a invisible non-collide box and getting touching parts.
local IgnoreList = {-- Add parts to ignore}
local Box = game.workspace.Model.SpawnBox
local TouchingParts = Box:GetTouchingParts()
for i = 1,#TouchingParts do
if table.find(IgnoreList,TouchingParts[i]) then
-- Do Nothing
else
--Clone Car
end
end
I would still recommend adding what I mentioned before. As if a player or another car is where the car is going to spawn then it will cause some issues.
ACTUALLY I’m wrong. For some reason the regenerate script only duplicates the car by the amount of players for some odd reason. Is it because the tool is in StarterPack? It works in client with only one player.