Hi, I am trying to make a script that teleports players on a specific team to a specific part.
The problem is it won’t do that, and there are no errors so I can’t tell why it’s not working, I do think it has something to do with player.team though.
local Map = script.Parent
local Players = game.Players:GetPlayers()
local StartMap = game.ServerScriptService.Script.StartMap
function teleportPlayers(player)
if player.Team == "Lithuania" then
player.Character.HumanoidRootPart.CFrame = Map.LithuanianSpawn.CFrame
end
if player.Team == "Russia" then
player.Character.HumanoidRootPart.CFrame = Map.RussiaSpawn.CFrame
end
end
StartMap.Event:Connect(teleportPlayers)
I think I might be wrong but the player.Team value type is an object type, which means you’ll have to localize the teams
local Map = script.Parent
local Players = game.Players:GetPlayers()
local StartMap = game.ServerScriptService.Script.StartMap
local Teams = game.Teams
function teleportPlayers(player)
if player.Team == Teams.Lithuania then
player.Character.HumanoidRootPart.CFrame = Map.LithuanianSpawn.CFrame
end
if player.Team == Teams.Russia then
player.Character.HumanoidRootPart.CFrame = Map.RussiaSpawn.CFrame
end
end
StartMap.Event:Connect(teleportPlayers)
First of all, you have to add a value to the teleportPlayers function, which you haven’t done in the StartMap.Event:Connect(teleportPlayers) line.
Considering you’re using a connect argument with a custom function, I’m not sure if you can add a value for the function which leaves it completely useless.
Right now I’m trying to find a way to kill all the players so they spawn, but it won’t work
local Map = script.Parent
local Players = game.Players:GetPlayers()
local StartMap = game.ServerScriptService.Script.StartMap
local Teams = game.Teams
function teleportPlayers()
for i,v in pairs(game.Players:GetChildren()) do
v.Character.Head:Destroy()
end
end
StartMap.Event:Connect(teleportPlayers)