Hi guys! I am trying to create a script that checks if the players is on the bright blue team and if they are then removes a charactermesh and replaces it with one from the workspace...although it isn't quite working or complete - any help would be greatly appreciated. Thanks :)
This is what I have so far, although it doesn't remove the old charactermesh and doesn't work :D
local TeamColor = BrickColor.new("Bright blue") local Player = game:GetService("Players").LocalPlayer local function Check() local mesh = game.Workspace.AgentLeftArm:Clone() mesh.Parent = Player end Player.Changed:connect(Check)
What you have set up right now inserts a new clone of AgentLeftArm in Workspace every time ANY property of the Player is changed. You are looking to see if a specific property [TeamColor] is changed to a specific value [BrickColor.new("Bright blue")].
local player = game.Players.LocalPlayer local teamColor = BrickColor.new("Bright blue") player.Changed:connect(function(property) if property == "TeamColor" then if player.TeamColor == teamColor then local mesh = game.Workspace.AgentLeftArm:Clone() mesh.Parent = player.Character -- What ever else you want here end end end)
But if I character respawns, the TeamColor property doesn't change. If you want to insert it into the character if it spawns in on the Bright blue Team then you'll need to have a CharacterAdded function as well.
local player = game.Players.LocalPlayer local teamColor = BrickColor.new("Bright blue") player.CharacterAdded:connect(function() if player.TeamColor == teamColor then repeat wait() until character:FindFirstChild("Humanoid") local mesh = game.Workspace.AgentLeftArm:Clone() mesh.Parent = player.Character -- What ever else you want here end end) player.Changed:connect(function(property) if property == "TeamColor" then if player.TeamColor == teamColor then local mesh = game.Workspace.AgentLeftArm:Clone() mesh.Parent = player.Character -- What ever else you want here end end end)
EDIT FIXED
local teamColor = BrickColor.new("Bright blue") game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if player.TeamColor == teamColor then repeat wait() until character:FindFirstChild("Humanoid") local mesh = game.Workspace.AgentLeftArm:Clone() mesh.Parent = character -- What ever else you want here end end) player.Changed:connect(function(property) if property == "TeamColor" then if player.TeamColor == teamColor then local mesh = game.Workspace.AgentLeftArm:Clone() mesh.Parent = player.Character -- What ever else you want here end end end) end)