When I press Q I go invisible like planned but only my head becomes visible again. Also my cooldown doesn' work.
CanLaunch = true cooldown = 3 cloaktime = 5 if CanLaunch == true then local player = game.Players.LocalPlayer:GetMouse() player.KeyDown:connect(function(key) if string.lower(key) == "q" then CanLaunch = false lPlyr = game.Players.LocalPlayer targets = lPlyr.Character for i, target in pairs(targets:GetChildren()) do if target:IsA("Part") then target.Transparency = .9 end end wait(cloaktime) for i, target in pairs(targets:GetChildren()) do if target:IsA("Part") then target.Transparency = 0 target.HumanoidRootPart.Transparency = 1 wait(cooldown) CanLaunch = true end end end end) end
FearMeIAmLag didn't list a reason that the HumanoidRootPart was broken, so I don't think they really knew.
The line is broken because HumanoidRootPart is a member of the Character, not the current target
in the loop. This causes an error. Additionally, each part would wait(cooldown)
before letting the next part in the loop become opaque again.
Moving those two lines outside of the for loop fixes both of those issues. (Also, adding an 's' to the target
before HumanoidRootPart)
CanLaunch = true cooldown = 3 cloaktime = 5 if CanLaunch == true then local player = game.Players.LocalPlayer:GetMouse() player.KeyDown:connect(function(key) if string.lower(key) == "q" then CanLaunch = false lPlyr = game.Players.LocalPlayer targets = lPlyr.Character for i, target in pairs(targets:GetChildren()) do if target:IsA("Part") then target.Transparency = .9 end end wait(cloaktime) for i, target in pairs(targets:GetChildren()) do if target:IsA("Part") then target.Transparency = 0 end end targets.HumanoidRootPart.Transparency = 1 wait(cooldown) CanLaunch = true end end) end