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

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

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

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

end

script.Parent.MouseButton1Down:connect(onClicked)?

1 answer

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.

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