I have two spawners and two teams(plum and black.) Neutral is set to false for both spawners. Yet, players always spawn at the plum spawner no matter what team they are on. Any ideas on what the flying fluff is going on here? Any ideas??
The second is picture shows that the player (me) is on the Black Team. Not sure why it didn’t load in.
Can you show me the script? We can’t solve this problem by not knowing what’s going on.
Sure! The goal is to change which spawner a player spawns at if they travel to another place in the game. So when they leave to go to the other place they change to the black team so that when they spawn back in I can spawn them on a ship and create a “flying back to base” animation. Here are the relevant parts of the code:
In Server Script parented to Workspace (I have prints to check what is running, sorry for the clutter):
Players = game:GetService(“Players”)
local Plum = game.Workspace.Spawns.Plum
local ReturnSpawner = game.Workspace.ReturnTransports.TransporterA.ReturnSpawner
local Returning = game.ReplicatedStorage.Returning
local DataService = game:GetService(“DataStoreService”)
local DataStore = DataService:GetDataStore(“AOTeamColor”)
local color
local function playerAdded(player)
local success = pcall(function()
color = DataStore:GetAsync(player.UserId)
print(color)
end)
print(“11”)
player.TeamColor = BrickColor.new(color)
print(player.TeamColor)
print("22")
if player.TeamColor ~= BrickColor.new("Plum") then
if player.TeamColor ~= BrickColor.new("Black") then
player.TeamColor = BrickColor.new("Plum")
end
end
print("33")
print(player.TeamColor)
if player.TeamColor == BrickColor.new("Plum") then
player.RespawnLocation = Plum
end
print("44")
if player.TeamColor== BrickColor.new("Black") then
player.RespawnLocation = ReturnSpawner
end
end
Players.PlayerAdded:Connect(playerAdded)
And here is the other code that changes to team to black when they join the ship that moves them to the other place:
prompt1.Triggered:Connect(function(player)
table.insert(Passangers, player)
print(Passangers)
local X = shipspawn.Position.X
local Y = shipspawn.Position.Y
local Z = shipspawn.Position.Z
glass.CanCollide = false
player.Character.PrimaryPart.CFrame = CFrame.new(Vector3.new(X,Y+3,Z))
glass.CanCollide = true
player.TeamColor = BrickColor.new("Black")
DataStore:SetAsync(player.UserId, "Black")
print("team color saved")
end)
When they hit the prompt they join the passenger list, move onto the ship, and change their team color. The ship is surrounded by a glass part and so I change the cancollide so the player can enter the ship.
The code is working. It is changing the teams and doing everything else it is supposed to. (I’ll add pcalls() once I have the code finalized.) The problem seems to be with the spawners. Am I missing something? I am totally confused.
Tell me what is your expected result, and tell me what is the actual result?
change the spawner names to the team names like
Plum spawner: Plum (caps matter)
Might work I found it on yt
I expect that when the player is on the Black team he will spawn on the Spawner for the Black team and when the player is on Plum he will spawn on the Plum spawner.
What actually happens is that the player always spawns on the Plum spawner even when on the Black team.
Thanks. I tried that and it did not work. I even tried changing the color of the spawner itself (desperation move.). Neither worked unfortunately.
I did see another youtube one that added the word “Spawn” at the end. forgot if it was capitalized. like “Plum Spawn”
you can try it if you want
Worth a try. Tried changing the names of the spawners by adding “Spawn”, with space, without a space, and not capitalized. Nothing.
Also tried throwing waits in, to see if it was a loading problem. Nothing.
Did all of your prints print in the output?
Yes, the prints show me that the code is doing what it is supposed to. Following the right “ifs…”
Please tell me why this piece of code is like this
First it says if it’s not plum and black, then it should be plum. So it is not randomized.
Yes, all players should be Plum unless they have gone to the other page. Then they will be Black when they get back so they spawn in the right place. Then change back to Plum.
The code is there to make sure that everyone is Plum unless they are coming back from the other place (where they play a game and then “fly back” on a ship.)
I really appreciate your help and any ideas that you have.
Have you heard of ands and ors?
if player.TeamColor ~= BrickColor.new("Plum") and player.TeamColor ~= BrickColor.new("Black") then
player.TeamColor = BrickColor.new("Plum")
end
This won’t really help but it is to neat your code.
Yes, that was an earlier version of the code. I changed it to the stacked conditionals in case that was the problem. I was worried about whether that would be read as ~= A and B or as ~=(A and B) so I played with the () and conditionals. But got no where. The conditionals work so I didn’t change it back.
Maybe put the script in ServerScriptService?