Add files via upload

This commit is contained in:
Sam Sneed 2024-04-19 15:24:56 -05:00 committed by GitHub
parent 25faa67878
commit 1e9bb73957
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View file

@ -1,5 +1,5 @@
{
"name": "Super Mario 64",
"name": "Sam 64",
"tree": {
"$className": "DataModel",

View 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)