Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What Math do I put to make players spawn in random spawns by pressing the Button GUI ( 9 spawns ) ? [closed]

Asked by 7 years ago
Edited 7 years ago

spawn = game.Workspace.SpawnLocation1 player = script.Parent.Parent.Parent.Parent

function onClicked() player.Character:MoveTo(spawn.Position)

end

script.Parent.MouseButton1Down:connect(onClicked)?

Closed as Not Constructive by Shawnyg

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 7 years ago

Ok so im assuming this is a normal script, which wont work in an actual Roblox place in player gui although it will work in studio. But you would use the built in lua function called math.random You also are going to want a model with all of the spawns in it.

-- all of the spawns
 Spawns = game.Workspace.Spawns:GetChildren()
player = script.Parent.Parent.Parent.Parent
function OnClicked()
-- chooses one of the 9 spawns randomly
local Spawn = Spawns[math.random(1,9)]
player.Character:MoveTo(spawn.Position)end
script.Parent.MouseButton1Down:connect(onClicked) 

Hope this helps.

Ad