Hi, is there a way for this script to not hit "HumanoidRootPart? and only hit “humanoid” so humanoidrootpart’s transparency wouldn’t be changed
I don’t know what I would have to write
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid") then
local hrp = hit.Parent:FindFirstChild("HumanoidRootPart") or hit.Parent.Parent:FindFirstChild("HumanoidRootPart")
hrp.Transparency = 0.5
end
end)
The Humanoid
is not an actual part rather just something to store the character’s info so It’s not possible to hit the Humanoid
Can you tell me what your script is supposed to do? This will let me help you easily
it’s to check if its a humanoid or not. I want the script to not hit HumanoidRootPart
HumanoidRootPart is usually invisible, is there anyway for the script to not change that part’s transparency?
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
for i, v in pairs(char:GetChildren()) do
if v.Name ~= "HumanoidRootPart" then
if v:IsA("Part") then
v.Transparency = .01
end
end
end
end
end)
this should be fine? i guess
But I want the script to not hit HumanoidRootPart! or it would become visible
like in the gif
https://i.gyazo.com/d9d8e989339c922d3f75f653d918755f.mp4
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid") then
local hrp = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
hrp.Transparency = 0.5
end
end)
Just check if its not HumanoidRootPart:
if hit.Name ~= "HumanoidRootPart" then
that makes HumanoidRootPart visible.
Just check if hit.Name == "HumanoidRootPart"
Thank you, I didn’t know about that.
I have another question, how can I make it make the hat invisible too?
I know it has to be with getchildren() and if v:IsA(“MeshPart”) but it doesn’t work
here is the full script:
Nevermind I already fixed it, thanks anyways!!!
local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
for _, v in ipairs(hit.Parent:GetDescendants()) do
if v.Name ~= "HumanoidRootPart" and v:IsA("BasePart") then
for i = 0, 100 do
v.Transparency += 0.01
end
end
end
end
end)
Old post, but this script should’ve been completely fine I believe.