I’m trying to make a GUI to change the player’s clothing but the buttons aren’t working (probably because of the way I’m listening for button activation) and if I manually fire the event with valid arguments it sets the ID for the shirt and pants but they don’t appear on the avatar.
The scripts are functions in a client and a server module script, there’re no errors but the buttons just don’t do anything and the clothing changing just causes the clothing not to appear on the avatar.
I’ve searched devforum and google but none of the methods I’ve tried have worked.
--Server side
local Event = game:GetService("ReplicatedStorage").Event
Event.OnServerEvent:Connect(function(Player, Uniform )
warn(Player)
local Character = Player.Character
if Character == nil then
warn("No character")
else
warn("Character")
Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=" .. Uniform.Top
Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=" .. Uniform.Bottoms
end
end)
--Button detection
for _, Button in pairs(Buttons) do
if Button == Buttons.Main then
Button[1].Activated:Connect(function()
warn("Main clicked")
if GUI_Visible == false then
for _, Button1 in pairs(Buttons) do
Button1[1].Visible = true
end
GUI_Visible = true
else
for _, Button1 in pairs(Buttons) do
Button1[1].Visible = false
end
GUI_Visible = false
end
end)
else
Button[1].Activated:Connect(function()
warn(Button .. "Clicked")
if Button[3] then
local Event = game:GetService("ReplicatedStorage").Event
Event:FireServer(Button.Uniform)
else
GUI.Popup.Visible = true
GUI.Popup.Alert:Play()
wait(3)
GUI.Popup.Visible = false
end
end)
end
end
--Buttons array
local Buttons = {
Main = {GUI.Uniforms},
Student = {GUI.Uniform_Buttons.Student, Uniform = Uniforms.Student, Auth = true},
Instructor = {GUI.Uniform_Buttons.Instructor, Uniform = Uniforms.Instructor, Auth = AuthLevel.InstructorAuth},
Staff = {GUI.Uniform_Buttons.Staff, Uniform = Uniforms.Staff, Auth = AuthLevel.StaffAuth},
Spectator = {GUI.Uniform_Buttons.Spectator, Uniform = Uniforms.Spectator, Auth = AuthLevel.SpectatorAuth},
Executive = {GUI.Uniform_Buttons.Executive, Uniform = Uniforms.Executive, Auth = AuthLevel.ExecutiveAuth}
}