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

Properly spawn a car in the workspace?

On my current project, I made a script for the car to regenerate every 300 seconds. Although there are no script errors, the car often spawns with one or more of the tires in a different Position in the Workspace than where it should be. This causes the car to have a seizure, players to be hit by the spasming tire and/or the tire to knock them into a seat of the car, even though the player is halfway across the Baseplate. Here is the code is used:

--Loughdough--

while true do
	local c = game.ServerStorage.Cars.SteelBlueCar:Clone()
	c.Parent = game.Workspace
	c:MakeJoints()
	
	wait(300)
	
	c:Destroy()
end

Is there a better way to do this? Thanks.

4 comments

0

You could try using MakeJoints before you parent it. No guarantees it will work, but it's worth a shot.

0

@Perci1 Yeah, thanks for trying. It only has seemed to make the cars fall apart upon spawning. Thanks for trying, though.

0

Is this with the default roblox chassis or a scripted one?

0

Try deleting the seat and adding a new one. It might be some of the properties of the seat that got messed up. This has happened to me and it's not your script. It has something to do with how you made the car.

2 answers

✓ Accepted answer

If your car is welded, ( as in welded together using a script ) then what you would probably want to do is, anchor the main brick the parts are welded to, clone the car ( using a script ), place it in workspace ( using script ), wait about, maybe 10 seconds after placed ( in script wait, ), then unanchor the brick, it should solve some problems, otherwise you can do something kind of cheeky and make a very tight space around the car and put that in workspace ( regularly ) then clone the car ( in script ) and make sure the car in replicated storage's position is inside the cage without touching any of the cage parts, and then jsut clone/spawn it there and that will try to keep it from spassing out. Those are some ways that may fix it, the anchored one has worked in the car community all the time :p, as it's what I and many other people use in the car community :p

2 comments

0

Thank you!

0

There's a car community? Wow. The more you know.

Try anchoring the Car in the ServerStorage and put this code on line 7

for i, v in pairs(c:GetChildren()) do--All Parts in the "c" should be ungrouped
	if v:IsA("Part") then --You might have to add some statements here such as: if  v:IsA("Part" or "WedgePart") then  
		v.Anchored = false
	end
end

Might not work, not sure, but might be worth a try.

1 comment

0

I'm almost certain this wouldn't work :P

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