Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My Role Skin Changer Isn't Executing, Any Help???

Error: 13:09:03.244 - ServerScriptService.Script:2: ')' expected (to close '(' at line 1) near 'player'

Script: game.player.PlayerAdded:connect(Function(player) Player.characteradded:connect(function(character) if player.team == game.Teams.COUNTER-TERRORISTS then character:waitforchild("Shirt").shirttemplate = "rbxassetid://2199673061" character:waitforchild("pants").pantstemplate = "rbxassetid://591736167" elseif player.team == game.Teams.TERRORISTS then character:waitforchild("Shirt").shirttemplate = "rbxassetid://2205729124" character:waitforchild("pants").pantstemplate = "rbxassetid://2333068761" else -- Load the player's default shirt and pants end end) )

2 comments

0
0

Thanks

1 answer

#Capitalisation

The problem is because almost all your code is in lowercase. Lua is case sensitive, so it won't know what you want if it is all in caps or all lowercase. All you really need to do is capitalise it correctly and you're done. And all keywords are in lowercase, so you do function and not Function. For parameters, it doesn't matter the casing style you prefer to use.

game.Players.PlayerAdded:Connect(function(Player) 
	Player.CharacterAdded:Connect(function(character) 
		if Player.Team == game.Teams["COUNTER-TERRORISTS"] then 
			-- Your team's name is not a valid identifier, it contains a hyphen, must be indexed with []
			character:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://2199673061" 
			-- Notice the PascalCase. 
			character:WaitForChild("Pants").PantsTemplate = "rbxassetid://591736167" 
		elseif Player.Team == game.Teams.TERRORISTS then
			-- No need to index with [], as this name is valid. But if desired you may.
	                character:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://2205729124" 
			character:WaitForChild("Pants").PantsTemplate= "rbxassetid://2333068761" 
		else
			 -- Load the player's default shirt and pants
		end 
	end)
end) 

Roblox automatically predicts what you want to type, so if you don't know how something should be written you can check the predictions, or use the wiki.

######Hopefully this answered your question and if it did don't forget to hit that accept button. If you have any more questions then feel free to leave them in the comments.

This discussion is preserved as it was. New answers, comments, and votes are closed.