local player = game.Players.LocalPlayer
local char = player.Character
char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
for i, v in ipairs(char:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "Head" then
v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
v.LocalTransparencyModifier = v.Transparency
end)
v.LocalTransparencyModifier = v.Transparency
char.ChildAdded:Connect(function(tool)
if tool:IsA("Tool") and tool:FindFirstChild("ACS_Settings") ~= nil then
if v:IsA("BasePart") and v.Name:match("Left Arm") or v.Name:match("Right Arm") then
v.Transparency = 1
end
end
end)
char.ChildRemoved:Connect(function(tool)
if tool:IsA("Tool") then
if v:IsA("BasePart") and v.Name:match("Left Arm") or v.Name:match("Right Arm") then
v.Transparency = 0
end
end
end)
end
end
What I’m trying to achieve: Make the players arms invisible when they have a gun from ACS equipped, then visible when an ACS weapon is unequipped. EDIT: There is no error. It just simply doesn’t work.
EDIT2: Also forgot to mention that it works for whenever they have the gun in their hand, it just doesn’t work whenever they unequip it. So the arms disappear, but do not reappear. I realize I was a bit vague with this. My apologies
local Players = game:GetService("Players")
local tool: Tool = script.Parent
local function UpdateArms(mouse: Mouse?)
local isEquipped: boolean = if mouse then true else false
local character: Model
xpcall(function()
character = tool.Parent.Parent.Character
end, function()
character = tool.Parent
end)
for _, value: BasePart? in ipairs(character:GetChildren()) do
if not value:IsA("BasePart") then
continue
end
if value.Name:split(" ")[2] == "Arm" then
value.Transparency = if isEquipped then 1 else 0
end
end
end
tool.Equipped:Connect(UpdateArms)
tool.Unequipped:Connect(UpdateArms)
If you want to make it invisible for all client you would need to use a remote event. Instead the function being inside the local script it would be inside the server script. The local script would be this:
local remoteEvent = ...
local function FireEvent(mouse: Mouse?)
remoteEvent:FireServer(if mouse then true else false)
end
tool.Equipped:Connect(FireEvent)
tool.Unequipped:Connect(FireEvent)
While on the server script will listen for the client.
local remoteEvent: RemoteEvent = script.Parent
local function UpdateArms(Player: Player, isEquipped: boolean)
local character = Player.Character
for _, value: BasePart? in ipairs(character:GetChildren()) do
if not value:IsA("BasePart") then
continue
end
if value.Name:split(" ")[2] == "Arm" then
value.Transparency = if isEquipped then 1 else 0
end
end
end
remoteEvent.OnClientEvent:Connect(UpdateArms)