I can’t seem to find a post on it. But the issue is it’s not passing the if statements so it’s something to do with the if statements not being defined right. I will be home soon so I can get on studio and text stuff and help you fix it.
alright thanks for your help i appreciate it
This doesn’t seem like a good idea, try this:
Players = game.Players
Players.PlayerAdded:Connect(function(player) -- Player is Added
Player.CharacterAdded:Connect(function(character) -- Character is Added
local Array = character:GetChildren() -- Array of Character
for i,v in Array do -- iterates through character
if v:IsA("BasePart") then -- if item is a Part (or Limb)
v.BrickColor = player.TeamColor -- Changes color to Team Color
end
end
end)
end)
where do i put the script? because its right now a server script inside StarterCharacterScripts
It would be best to put this inside ServerScriptService
, so it works for the entire server
i have to add locals right?
because its light red lined
(Players And Player)
what do i need to make the locals?
Pretty sure this isnt working because the character reloads when it finds a spawnpoint to go to and that each character has a instance called BodyColor inside of them which sort of masks over the parts color.
if you disable the spawnpoint you will see your scripts works until the player resets as the bodycolors then come into affect
here is my solution to this
not sure how efficient this method is but hopefully it will work for you!
-- // Script Made by DARKMASTER6906 // --
--// Services
local Players = game:GetService("Players")
local TM = game:GetService("Teams")
--// Tables
local conn = {} --this should prevent memory leaks
--// Functions
local function playerAdded(Player)
conn[Player] = {}
conn[Player][#conn[Player] + 1] = Player.CharacterAdded:Connect(function(Char)
repeat wait() until Char:FindFirstChild("Humanoid") and Char:FindFirstChild("Body Colors")
local TeamColor = Player.Team.TeamColor
local BodyColors = Char:FindFirstChild("Body Colors")
for i, part in pairs(Char:GetChildren()) do
if part:IsA("BasePart") then
part.BrickColor = TeamColor
print(part.BrickColor)
end
end
BodyColors.HeadColor = TeamColor
BodyColors.LeftArmColor = TeamColor
BodyColors.LeftLegColor = TeamColor
BodyColors.RightArmColor = TeamColor
BodyColors.RightLegColor = TeamColor
BodyColors.TorsoColor = TeamColor
end)
end
for i, team in pairs(TM:GetChildren()) do
team.PlayerAdded:Connect(playerAdded)
end
--// This disconnects that character function when the player leaves the game
Players.PlayerRemoving:Connect(function(Player)
for i, connect in pairs(conn[Player]) do
connect:Disconnect()
conn[Player][i] = nil
if #conn[Player] <= 0 then
conn[Player] = nil
end
end
end)
Two Ways:
Players = game.Players -- Global Variable
local Players = game.Players -- Local Variable (only accessible within a scope)
where do i put this script and in what type of script?
ServerScriptService as a normal script
You can just Remove it, there is no real issue caused by doing so.
i really dont know what i’m doing wrong but both dont seem to work yet
From the testing, that never worked, maybe I did it wrong but yeah
you need the Player Instance
so:
game.Players.PlayerAdded:Connect(SomeRandomPlayerHere) -- the Player
SomeRandomPlayerHere.CharacterAdded:connect(function(character)
-- code
end)
end)
oh wait, @darkvrn’s script does work i forgot to add body colors
but i still can try @DasKairo’s script
i dont understand what you mean?
what do i have to put at the “SomeRandomPlayerHere”