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?
script.Parent.Activated:Connect(function()
local player = script.Parent.Parent.Parent.Parent.Parent --plr name
local p = script.Parent.Pants.PantsTemplate --pants are being stored in parent
local s = script.Parent.Shirt.ShirtTemplate --shirts are being stored in parent
local foundShirt = player.Character:FindFirstChild("Shirt") -- Tries to find Shirt
if not foundShirt then -- if there is no shirt
print("No shirt found, creating for "..player.Name)
local newShirt = Instance.new("Shirt",player.Character)
newShirt.Name = "Shirt"
else if foundShirt then -- if there is a shirt
print("Shirt found, reconstructing for "..player.Name)
player.Character.Shirt:remove()
local newShirt = Instance.new("Shirt",player.Character)
newShirt.Name = "Shirt"
end
end
I have this hooked up to a text button. Thanks.

1 comment
Anytime you want something to happen "globally"(on the server) you must run it on the server. Here' is a good resource you help you out. https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events