So basically, I spent a good lot of time making this GUI for a guy, runs smoothly in Solo test but when I apply it to multiplayer it doesn't work! I am really confused here, does anybody see a problem?
.
1 | script.Parent.MouseButton 1 Down:connect( function () |
2 | playername = script.Parent.Parent.Parent.Parent.Name |
3 | player = Workspace:FindFirstChild( "" ..playername.. "" ) |
4 | if player ~ = nil then |
5 | player:FindFirstChild( "Pants" ).PantsTemplate = "http://www.roblox.com/asset/?id=160490493" |
6 | player:FindFirstChild( "Shirt" ).ShirtTemplate = "http://www.roblox.com/asset/?id=160490464" |
7 | end |
8 | end ) |
I'm guessing it's not a LocalScript which is required when using GUIs. Make it a LocalScript.
An easier way of getting the character is by using the Character property from Player.
player.Character
01 | -- LocalScript |
02 | local player = game:GetService( "Players" ).LocalPlayer -- Gets the player, only works in LocalScripts. |
03 | repeat wait() until player.Character -- Will loop until it gets the players Character. |
04 |
05 | script.Parent.MouseButton 1 Down:connect( function () -- Makes the event. |
06 | local pants = player.Character:FindFirstChild( "Pants" ) |
07 | local shirt = player.Character:FindFirstChild( "Shirt" ) |
08 | if pants and shirt then -- If it finds the pants and shirt |
09 | pants.PantsTemplate = "http://www.roblox.com/asset/?id=160490493" |
10 | shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=160490464" |
11 | end |
12 | end ) |
If your friend uses FilteringEnabled then this won't work, you'd have to learn to use these: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial
The only thing that could be wrong is that it cannot find a 'Pants' or 'Shirt' Instance in the character model.