I unchecked neutral on all of them and now i just spawn over the void. And If I uncheck netraul on all but 1 i just always spawn at that 1 spawn point no mater what team im on.
consider using this function to speed up giving teams
local cache = {}
local function getPlayerRankInGroup(player:Player, group:number)
if not cache[player] then
cache[player] = {}
player.AncestryChanged:Once(function()
cache[player] = nil
end)
end
if cache[player][group] then
return cache[player][group]
end
cache[player][group] = player:GetRankInGroup(group)
return cache[player][group]
end
so instead of doing plr:GetRankInGroup(34363373) you do
getPlayerRankInGroup(plr, 34363373)
And about your problem:
I have a question as to why you use a remote event here? Shouldn’t this be a one time thing when the player joins the game?
Using a remote event cuz my loading screen is handled in a localscript so I am firing the remoteevent after the loading screen is done loading.
But I also have a seperate script that literally manually places the player at their correct spawn after joining which works fine but when they reset ingame they spawn at the wrong locations.
Nah i dont want that cuz I was working on it all day yesterday to make sure jailed people spawn in the jail.
But sure here it is:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage.Events
local SpawnPoints = workspace:WaitForChild("SpawnPoints")
-- Define the server event handler for spawning players
Events.SpawnPlayer.OnServerEvent:Connect(function(player)
local character = player.Character
local isArrested = player:WaitForChild("JailSystem").isArrested
local TimeLeft = player:WaitForChild("JailSystem").TimeLeft
-- Wait for the player's character to load
if not character or not character.Parent then
character = player.CharacterAdded:Wait()
end
-- Check the player's group rank
local groupId = 34363373 -- Replace with your group ID
local rank = player:GetRankInGroup(groupId)
-- Define spawn points based on rank conditions
if player.JailSystem.isArrested.Value == true then
character:MoveTo(SpawnPoints.JailSpawn.Position)
player.PlayerGui:WaitForChild("TimeLeftArrested").Frame.Visible = true
for remainingTime = TimeLeft.Value,0 , -1 do
player.PlayerGui.TimeLeftArrested.Frame.TimeLeft.Text = "Time Left: "..remainingTime
wait(1)
end
isArrested.Value = false
TimeLeft.Value = 0
player:LoadCharacter()
elseif rank >= 200 then
character:MoveTo(SpawnPoints.Headquarters.Position)
elseif rank >= 14 then
character:MoveTo(SpawnPoints.Headquarters.Position)
elseif rank >= 8 then
character:MoveTo(SpawnPoints.Officers.Position)
elseif player:IsInGroup(34364980) then -- Example of checking another group
character:MoveTo(SpawnPoints.Infantry15.Position)
elseif player:IsInGroup(0000) then -- Replace with the group ID
character:MoveTo(SpawnPoints.Armored6.Position)
else
-- Default spawn point or handling for players not in specified groups
character:MoveTo(SpawnPoints.Civilians.Position)
end
end)
My spawn issue was never fixed. Like not on spawning, that works perfectly but after a player dies or resets. They spawn at the wrong spawnpoint, is it possible to make a script that like manually places them at their spawn point.
I tried doing this but it didnt seem to work.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage.Events
local SpawnPoints = workspace:WaitForChild("SpawnPoints")
game.Players.PlayerAdded:Connect(function(plr)
local character = plr.Character
character.Humanoid.Died:Connect(function()
wait(plr.CharacterAppearanceLoaded)
if plr.Team == game.Teams["15th Infantry Division"] then
plr.Character:MoveTo(SpawnPoints.Infantry15.Position)
elseif plr.Team == game.Teams["British Army Personnel"] then
plr.Character:MoveTo(SpawnPoints.Infantry15.Position)
elseif plr.Team == game.Teams["Chiefs of Staff"] then
plr.Character:MoveTo(SpawnPoints.Headquarters.Position)
elseif plr.Team == game.Teams["Civilians"] then
plr.Character:MoveTo(SpawnPoints.Civilians.Position)
elseif plr.Team == game.Teams["Field Grade Officers"] then
plr.Character:MoveTo(SpawnPoints.Officers.Position)
elseif plr.Team == game.Teams["General Grade Officers"] then
plr.Character:MoveTo(SpawnPoints.Headquarters.Position)
elseif plr.Team == game.Teams["Headquarters"] then
plr.Character:MoveTo(SpawnPoints.Headquarters.Position)
elseif plr.Team == game.Teams["Jailed"] then
plr.Character:MoveTo(SpawnPoints.JailSpawn.Position)
elseif plr.Team == game.Teams["Junior Officers"] then
plr.Character:MoveTo(SpawnPoints.Officers.Position)
elseif plr.Team == game.Teams["Royal Military Police"] then
plr.Character:MoveTo(SpawnPoints.RMPSpawn.Position)
end
end)
end)```