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

I made a GUI that gives you clothes but it doesnt work server wide. How do I fix it?

I made a fully function GUI that gives you clothes depending on which button you click on. The only thing is, the clothes dont show server wide. What I mean by this is if player 1 clicked on shirt 1 then he would see the shirt on his screen, but player 2 would see player 1's default clothes. I have tried changing the script from a local script to just a normal script but then it break completely. Heres an example of the script (It is inside of a text button and local script)

local playername = game.Players.LocalPlayer.Name
local player = workspace:FindFirstChild(""..playername.."")
local ShirtID = "http://www.roblox.com/asset/?id=873496662"
local PantsID = "http://www.roblox.com/asset/?id=873589284"

function shirthing()
	player:FindFirstChild("Shirt").ShirtTemplate = ShirtID
	player:FindFirstChild("Pants").PantsTemplate = PantsID

end





script.Parent.MouseButton1Down:connect(shirthing)

1 answer

✓ Accepted answer

First off, insert a RemoteEvent in ReplicatedStorage. Name it whatever you want. Then, make a script in ServerScriptService.

-- local script (inside the button)

local player = game.Players.LocalPlayer
local char = player.Character -- this replaces your findFirstChild() since the char is literally the model inside workspace.
local ShirtID = "http://www.roblox.com/asset/?id=873496662"
local PantsID = "http://www.roblox.com/asset/?id=873589284"

function shirthing()
	game.ReplicatedStorage.RemoteEvent:FireServer(ShirtID, PantsID)
end

script.Parent.MouseButton1Down:connect(shirthing)

Now, the server script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, ShirtID, PantsID)
	local char = player.Character
char:FindFirstChild("Shirt").ShirtTemplate = ShirtID
char:FindFirstChild("Pants").PantsTemplate = PantsID
end)

3 comments

0

How would I go about doing this for multiple text buttons? Would I have to repeat the script over and over?

0

kind of. and if you want to, in the fireserver parenthesis, add the shirtID and pantsID parameters

0

ive modified the script so it works for multiple.

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