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

How do I get a model to spawn on top of a part when a TextButton is pressed? Trying to spawn a Car.

Hi there, I am making a button that spawns a car in a certain location on top of a part to be exact. The car is a model and uses an AC6 chassis. Could anyone please help? The car needs to be driveable and The text button is in startergui.

1 comment

0

Models have property called PrimaryPart, to move whole model use :SetPrimaryPartCFrame (model's function). Button has event called MouseButton1Click, it will fire whenever the button is pressed.

1 answer

✓ Accepted answer

Well, this site is not a request site. So, I can't provide you with the script, that will be called script-feeding, if I just provide you with the script. But here is some help:

First, get the position of the PrimaryPart. Then, you can set the CFrame of the model using SetPrimaryCFrame in the script. https://developer.roblox.com/en-us/api-reference/function/Model/SetPrimaryPartCFrame

Second, put the model in ReplicatedStorage and now you have Clone it. https://developer.roblox.com/en-us/api-reference/function/Instance/Clone And then you can SetPrimaryCFrame on the cloned model.

Third and the last, you have to use MouseButtonClick events and RemoteEvents, and on the server side you have to Clone. https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

I recommend you to use RemoteFunctions instead.

Lemme know if it helps!

2 comments

0

Thank you, I want the car to be visible to all players though. So should it be in ServerStorage?

0

Well, you can keep it in ServerStorage to prevent exploitation and then clone the model of the car and then make the parent workspace

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