Ad
Log in to vote
1

How to make a script that spawns a model on button click?

Asked by
Xyternal 192
4 months ago
Edited 4 months ago

Hello everyone! I was creating a boat fighting game where people have to press a button, and the boat model will spawn. I have constructed the boat and all, but I still don't know how to make the script (I am really, really new to scripting). Can you please send me links to tutorials? Or better, give me instructions on what to do? Thank you!

0
I always recommend peaspod for people who wanna get into scripting: https://www.youtube.com/watch?v=v3dbJXSa12Q&list=PLXX6hhg4CysYf0M-_GtCEOgGlkBfrXsoJ prooheckcp 340 — 4mo
0
Alright thank you! Xyternal 192 — 4mo

1 answer

Log in to vote
0
Answered by 4 months ago

So I'm a little new to scripting as well but I think this would work. What you can do is add the boat model into lighting then clone it and set the parent to workspace or whatever. Then set the position.

Boat = game.Lighting.BoatModel --wherever your boat model is
button = game.StarterGui.Button -- wherever your button is

button.MouseButton1Click:Connect(function()
    BoatClone = Boat:Clone() -- clones the Boat
    BoatClone.Parent = workspace -- Sets the parent to workspace
    BoatClone.Position = Vector3.new(0,0,0) -- zero,zero,zero is the middle of the world
end)

This should work, I might have some syntax error though. Sorry I can't check it as I am currently at school and they have blocked Roblox studio ;(

0
Thank you very much. I will try this solution out Xyternal 192 — 4mo
Ad

Answer this question