So basically, the script needs to change the player's shirt and pants depending on what team they're on. Currently, the script is in StarterGui, but the problem is that the clothes only appear for your avatar, and not for others (and vice versa).
How would I re-code/re-format this script to be located in ServerScriptService, so that I make make the server change the clothes instead?
local player = game.Players.LocalPlayer
local character = player.Character
player:WaitForChild("cEvent").OnClientEvent:connect(function()
if player.TeamColor == game.Teams["Axis Forces"].TeamColor then --[[ This will get the teamname, instead of the color.]]
if character:FindFirstChild("Shirt") then
character.Shirt:Destroy()
end
if character:FindFirstChild("Pants") then
character.Pants:Destroy()
end
Instance.new("Shirt",character).ShirtTemplate = "http://www.roblox.com/asset/?id=356273812"
Instance.new("Pants",character).PantsTemplate = "http://www.roblox.com/asset/?id=356262036"
end
end)
I was thinking to change the 'OnClientEvent' part to 'PlayerAdded', but that doesn't seem to work.

2 comments
Put the shirt on the persons character in Workspace as well.
More information is needed to answer this question, because you're using a server-to-client event and therefore already have a server script. We'd need to see the server script to be able to tell you anything.