I am making a murder type game, I have no clue how to make it so that it teleports players, but have attempted it. Here is the code.
--SpyxSpy main script
local spawns = {"Spawn1", "Spawn2", "Spawn3", "Spawn4", "Spawn5", "Spawn6"}
local selectedSpawn = spawns[math.random(1, #spawns)]
local Teleport = selectedSpawn
local spawn = workspace[selectedSpawn]
local Roles = {"Scientist", "Spy", "Soldier"}
local RoleMaxes = {6, 1, 2, 1}
local filled = {0, 0, 0, 0}
local function chooseRole()
local open = {}
for i = 1, #Roles do
if filled[i] < RoleMaxes[i] then
table.insert(open, i)
end
end
local randomOpen = open[math.random(1, #open)]
filled[randomOpen] = filled[randomOpen] + 1
return Roles[randomOpen]
end
local selectedRole = chooseRole()
print(selectedRole)
if selectedRole == "Scientist" then
game.StarterGui.ClassGui.Frame.TextLabel.TextSize = 50
game.StarterGui.ClassGui.Frame.TextLabel.Text = "Scientist, stick with soldiers!"
wait(2)
game.StarterGui.ClassGui.Frame.Visible = false
end
if selectedRole == "Soldier" then
game.StarterGui.ClassGui.Frame.TextLabel.TextSize = 50
game.StarterGui.ClassGui.Frame.TextLabel.Text = "Soldier, protect scientists against the spy!"
wait(2)
game.StarterGui.ClassGui.Frame.Visible = false
end
if selectedRole == "Spy" then
game.StarterGui.ClassGui.Frame.TextLabel.TextSize = 50
game.StarterGui.ClassGui.Frame.TextLabel.Text = "Spy, kill soldiers and scientists, and gather data!"
wait(2)
game.StarterGui.ClassGui.Frame.Visible = false
end
local Pos = script.Parent.Parent:findFirstChild(Teleport)
Player:moveTo(Pos.Position)

1 comment
Feel free to ask any questions!