Trying to make this server sided... not working!

This is a bit frustrating, I don’t know if I’m making an obvious mistake here.

Hello developers, I’m trying to change the players outfits when they join the server via script in serverscriptservice.

Here is the image of the script’s location

Problem

game:GetService("Players").PlayerAdded:Connect(function()
	for i,v in pairs(game:GetService("Players"):GetPlayers()) do
		v.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=11108169086"
		v.Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=129459076"
	end
end)

How could I remaster the script so players can see others wearing the outfit and not just themselves (It is client sided and I am not sure why).

Thanks, cal.

also, this what it looks like on server from player’s perspectives (imagine player1, and player2)

I see the issue here.

Replace “for i,v in pairs(game:GetService(“Players”):GetPlayers()) do” with a CharacterAdded:Connect(function() event. If it doesn’t try doing :WaitForChild(“Shirt”).

I believe its because when a player is added their character isn’t immediately loaded.

2 Likes

So I would have to make a remote event?

Sorry, I couldn’t really understand this. Could you elaborate please?

CharacterAdded is an event, you can read about events on create.roblox.com

game:GetService("Players").PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Shirt, Pants = Character:WaitForChild("Shirt"), Character:WaitForChild("Pants")

        Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=11108169086"
        Pants.PantsTemplate = "http://www.roblox.com/asset/?id=129459076"
    end)
end)
1 Like

Sorry for not researching in advance. Thank you for the script.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.