Stuck On Shirt Changing GUI

Hello Developers! I am trying to create a GUI for my game that changes player’s shirts so then admins can turn staff into uniform if they refuse.

The only thing is, I am having trouble and it is not working.

Help would be great!

Screen Shot 2020-04-19 at 12.27.21 pm

Script In Text Button

local plr = script.Parent.Parent.TextBox.Text

script.Parent.MouseButton1Click:Connect(function()

game.ReplicatedStorage.ChangeClothes:FireServer(plr)

end)

Script Handling Remote

game.ReplicatedStorage.ChangeClothes.OnServerEvent:Connect(function(p, plr)

game.Workspace[plr].Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=2733806108"

end)

Remote Event

Screen Shot 2020-04-19 at 12.29.19 pm

I have a script like this in one of my Text Buttons, try using this script inside of the text button

print(“Close button loaded”)

button = script.Parent

window = button.Parent

function onClicked(GUI)

window:remove()

end

script.Parent.MouseButton1Click:connect(onClicked)

I recommend creating a bigger text box with 0.7 Transparency that covers the entire screen, and put the script into it. You could also put a TextLabel saying “Click Anywhere to Hide”.

1 Like

Thats really simple. The main thing is what I want in the post’s description.

Sorry, all I read was the title and the scripts!

1 Like

I am curious if you get any error in output or not but I’d use this on client just to not make variable constant maybe.

script.Parent.MouseButton1Click:Connect(function()
    local plr = script.Parent.Parent.TextBox.Text
    game.ReplicatedStorage.ChangeClothes:FireServer(plr)
end)
2 Likes

I am not sure, but the problem might be that if you write the name wrong, it will output an error.
Maybe you can try getting the player from it’s name (check if the player even exists), then change his shirt from his character.
I’ll test my solution, and edit my post if it works for me.

1 Like

I managed to get it to work, what I have done differently, is that I got the text from the textBox, not from the parent, but from the local player, and now it works.
local script:

local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.ChangeClothes:FireServer(player.PlayerGui.Test.TextBox.Text)
	print(player.PlayerGui.Test.TextBox.Text)
end)

Replace Test with the name of your screenGui, and if you have also a frame, add .Frame to the screengui, but instead the .frame, write the name of the frame
Server Script:

game.ReplicatedStorage.ChangeClothes.OnServerEvent:Connect(function(p, plr)
	print(plr)
	if(game.Players:FindFirstChild(plr)) then
		local player = game.Players:WaitForChild(plr)
		player.Character:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=2733806108"
	end

end)

@Aiden_12114 , does it work for you? I saw you liked my post but you did not reply if it worked or not, if it does, please accept my answer as the solution, so other people will know it is solved :grinning:

1 Like

I have not tried it yet. I will right now!

1 Like

Have you tried it? Deos it work? it works for me though.

What I believe is that you don’t have to do it on the server side necessarily. Doing it in the client side would be visible to all the other players.

Are you sure about that pranvexploder? Client changes can only be seen by the client, only for animations I believe it’s different.
I don’t think that local scripts can change other players’ clothing.
Edit: Pranvexploder, it does not work, changing it using the client does not work, what basically happens, is just the player that clicks the button can see the other player with the shirt, but the others can’t, because it affects only on 1 client.
this is my local script inside the button:

local playerReal = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local plr = playerReal.PlayerGui.Test.TextBox.Text
	if(game.Players:FindFirstChild(plr)) then
		local player = game.Players:WaitForChild(plr)
		player.Character:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=2733806108"
	end
end)

I believe it applies to shirts and pants too.

1 Like

Thank you so much! It works! :smiley:

1 Like