Hey, so I'm making a GUI that allows you to change shirt upon pressing a button. After finishing up I went to test on a local server so I could see the script working on other players, but I could see the script only worked locally (on the player who pressed the button's screen) and his clothes were being removed. How would I fix this?
01 | script.Parent.Activated:Connect( function () |
02 | local player = script.Parent.Parent.Parent.Parent.Parent --plr name |
03 | local p = script.Parent.Pants.PantsTemplate --pants are being stored in parent |
04 | local s = script.Parent.Shirt.ShirtTemplate --shirts are being stored in parent |
05 | local foundShirt = player.Character:FindFirstChild( "Shirt" ) -- Tries to find Shirt |
06 | if not foundShirt then -- if there is no shirt |
07 | print ( "No shirt found, creating for " ..player.Name) |
08 | local newShirt = Instance.new( "Shirt" ,player.Character) |
09 | newShirt.Name = "Shirt" |
10 | else if foundShirt then -- if there is a shirt |
11 | print ( "Shirt found, reconstructing for " ..player.Name) |
12 | player.Character.Shirt:remove() |
13 | local newShirt = Instance.new( "Shirt" ,player.Character) |
14 | newShirt.Name = "Shirt" |
15 | end |
16 | end |
I have this hooked up to a text button. Thanks.
You must change it on the server, or use FilteringEnabled false (unsupported for good reason).
Use RemoteEvents:
https://developer.roblox.com/en-us/articles/Roblox-Client-Server-Model
https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
https://developer.roblox.com/en-us/api-reference/class/RemoteEvent