I’m working on a game! I am trying to make it so that when you equip it shows your arms and vice versa.
The problem is there is not negative output in Roblox Studio and I can’t figure it out, I tried multiple ways to fix it but it is still the same.
Here is my script:
local character = player.Character or player.CharacterAdded:Wait()
local function ShowArms()
game:GetService("RunService").RenderStepped:Connect(function()
for i, part in pairs (character:GetChildren()) do
if string.match (part.Name,"Right Arm") or string.match (part.Name, "Left Arm") then
part.LocalTransparencyModifier = 0
end
end
end)
end
local function HideArms()
game:GetService("RunService").RenderStepped:Connect(function()
for i, part in pairs (character:GetChildren()) do
if string.match (part.Name,"Right Arm") or string.match (part.Name, "Left Arm") then
part.LocalTransparencyModifier = 1
end
end
end)
end
while true do
task.wait()
player.ChildAdded:Connect(function(item)
if item:IsA("Tool") then
HideArms()
print("HideArms succesfully")
else
player.ChildRemoved:Connect(function()
ShowArms()
print("ShowArms succesfully")
end)
end
end)
end
local function ShowArms()
for i, part in pairs (character:GetChildren()) do
if string.find (part.Name,"Hand") or string.find (part.Name,"Arm") then
part.LocalTransparencyModifier = 0
end
end
end
local function HideArms()
for i, part in pairs (character:GetChildren()) do
if string.find (part.Name,"Hand") or string.find (part.Name,"Arm") then
part.LocalTransparencyModifier = 1
end
end
end
character.ChildAdded:Connect(function(item)
if item:IsA("Tool") then
HideArms()
print("HideArms succesfully")
end
end)
character.ChildRemoved:Connect(function(item)
if item:IsA("Tool") then
ShowArms()
print("ShowArms succesfully")
end
end)
Maybe it’s because you’re trying to connect the ChildAdded and ChildRemoved events inside a while loop which could be causing multiple connections to be made every time the loop iterates.
Try this and let me know if it works>
local character = player.Character or player.CharacterAdded:Wait()
local function ShowArms()
for i, part in pairs (character:GetChildren()) do
if string.match (part.Name,"Right Arm") or string.match (part.Name, "Left Arm") then
part.LocalTransparencyModifier = 0
end
end
end
local function HideArms()
for i, part in pairs (character:GetChildren()) do
if string.match (part.Name,"Right Arm") or string.match (part.Name, "Left Arm") then
part.LocalTransparencyModifier = 1
end
end
end
player.ChildAdded:Connect(function(item)
if item:IsA("Tool") then
HideArms()
print("HideArms successfully")
end
end)
player.ChildRemoved:Connect(function(item)
if item:IsA("Tool") then
ShowArms()
print("ShowArms successfully")
end
end)
Thank you guys for the help but is there a reason why the hands are not showing when I’m equipping something it prints out successfully but I don’t apparently see my arms ? (btw the game is first-person lock)
The CharacterAdded event is fired before the character’s parts (like the arms) are loaded into the game. So when you call player.Character or player.CharacterAdded:Wait(), the character’s parts may not exist yet, causing your ShowArms and HideArms functions to not work as expected.
To fix this, you could use the ChildAdded event of the character to wait for the arms to be added
Try this,
local function ShowArms(character)
for i, part in pairs (character:GetChildren()) do
if string.match (part.Name,"Right Arm") or string.match (part.Name, "Left Arm") then
part.LocalTransparencyModifier = 0
end
end
end
local function HideArms(character)
for i, part in pairs (character:GetChildren()) do
if string.match (part.Name,"Right Arm") or string.match (part.Name, "Left Arm") then
part.LocalTransparencyModifier = 1
end
end
end
local function onCharacterAdded(character)
character.ChildAdded:Connect(function(child)
if child.Name == "Right Arm" or child.Name == "Left Arm" then
if #character:GetChildren("Tool") > 0 then
HideArms(character)
else
ShowArms(character)
end
end
end)
end
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then onCharacterAdded(player.Character) end
player.ChildAdded:Connect(function(item)
if item:IsA("Tool") then
HideArms(player.Character)
print("HideArms successfully")
end
end)
player.ChildRemoved:Connect(function(item)
if item:IsA("Tool") then
ShowArms(player.Character)
print("ShowArms successfully")
end
end)
The script doesn’t work because I think the problem is the local functions I made HideArms() and ShowArms(), I tried your script but it still doesn’t work. I placed the script at StarterGui?
I have an alternative but it’s a bit complicated.
You can clone the arms and the humanoid and put it in a seprate model, the arms copy the position of the actual arms in renderstepped, and the unequip and equip you can just use transparency for it