I’m currently trying to make an admin panel and ran into an issue.
I was trying to make an invisibility command for it, so that you could click “Invisible” to go Invisible, and “Visible” to go visible. But I digress, I need help with a script. When you click the TextButton, it does makes everything but the accessories on my character disappear.
It was expectant that it would do this, as the script doesn’t include hats and whatnot, but I’m not exactly sure how to make accessories disappear and reappear.
Accessories consist of the accessory object, and the Handle, a meshpart that is the actual 3D hat.
You can use a loop, which you can also use to make the limbs disappear.
local player = game.Players.LocalPlayer
local function onButtonClicked()
game.StarterGui.ScreenGui.Click:Play()-- not sure about this, StarterGui isn't a place to store sounds
for i,v in pairs(player.Character:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 1
elseif v:IsA("Accessory") then
v.Handle.Transparency = 1
end
end
end
script.Parent.MouseButton1Click:Connect(onButtonClicked)
Also, making the function local is faster, and :connect is deprecated in favor of :Connect
I already edited zamd157’s script and came up with a working one.
function onButtonClicked()
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
game.StarterGui.ScreenGui.Click:Play()-- not sure about this, StarterGui isn't a place to store sounds
for i,v in pairs(player.Character:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 1
elseif v:IsA("Accessory") then
v.Handle.Transparency = 1
end
end
end
script.Parent.MouseButton1Click:Connect(onButtonClicked)