Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make clothing change globally instead of locally?

Asked by 5 years ago

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
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 ForeverBrown 356 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

0
Thanks. I used a remote event to trigger the script. jensar141215 157 — 5y
0
Glad I could help. :) Sonnenroboter 336 — 5y
0
FilteringEnabled can't be false programmerHere 371 — 5y
0
"unsupported for good reason" Sonnenroboter 336 — 5y
Ad

Answer this question