Ok so when I click the text button I want the model "Ship" in Lighting to clone, and go into Workspace. I can't figure out how to run the function when I click the button!Heres my script!
1 | function onClick() |
2 | local ship = game.Lighting.Ship:Clone() |
3 | ship.Name = "TheShip" |
4 | ship.Parent = game.Workspace |
5 | end |
So when I'd add onClick() to run the function, what would I write?
If you want the function to be called whenever the GUI is clicked, just connect()
it to the MouseButton1Down
event.
1 | script.Parent.MouseButton 1 Down:connect(onClick) |
On a side note, you really should store objects in ServerStorage or ReplicatedStorage instead of Lighting.