Add files via upload
This commit is contained in:
parent
25faa67878
commit
1e9bb73957
2 changed files with 31 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "Super Mario 64",
|
||||
"name": "Sam 64",
|
||||
|
||||
"tree": {
|
||||
"$className": "DataModel",
|
||||
|
|
30
server/SpawnPoints/SpawnPoints.server.lua
Normal file
30
server/SpawnPoints/SpawnPoints.server.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
-- Function to move the player's character to a random spawn location of the same team color
|
||||
local function movePlayerToTeamSpawn(player)
|
||||
local teamColor = player.TeamColor
|
||||
local spawnLocations = game.Workspace:FindPartsInRegion3(nil, game.Workspace.Map.SpawnRegions:GetChildren()) -- Assuming SpawnRegions are separate parts
|
||||
local teamSpawn = nil
|
||||
|
||||
-- Find a spawn location with the same TeamColor as the player's team
|
||||
for _, spawn in pairs(spawnLocations) do
|
||||
if spawn.TeamColor == teamColor then
|
||||
teamSpawn = spawn
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if teamSpawn then
|
||||
player.Character:SetPrimaryPartCFrame(CFrame.new(teamSpawn.Position))
|
||||
else
|
||||
warn("No spawn location found for team color: " .. tostring(teamColor))
|
||||
end
|
||||
end
|
||||
|
||||
-- Connect the function to player respawning
|
||||
game.Players.PlayerAdded:Connect(function(player)
|
||||
player.RespawnLocation = nil -- Make sure player has no pre-defined respawn location
|
||||
|
||||
player.CharacterAdded:Connect(function(character)
|
||||
-- Move player to team spawn on character added (respawn)
|
||||
movePlayerToTeamSpawn(player)
|
||||
end)
|
||||
end)
|
Loading…
Reference in a new issue