Hi, it’s potato. So I’m trying to make a script that makes it so that if you touch an object, your head becomes visible again. (It had been lost, so now your trying to find it, for a little bit of backround.) I’m not sure what I’m doing wrong there are no errors popping up or anything. (At least not that I can see.) I’m pretty new to scripting, and I was hoping it would be as simple as changing a few things in another script I did, but I guess not.
Here is the script so far.
local trap = script.Parent
local function onTouch(LostHead)
local character = LostHead.Parent
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.head.transparency = 0
end
end
trap.Touched:Connect(onTouch)
Please help if anyone knows what I did wrong, it’s probably something really simple but like I said I’m not very good at scripting.
So I replaced it with what you said, but I’m still running into errors with the script. The second end is underlined in red, and if I delete it it just makes more problems appear, any ideas?
Oh yeah, you’ll have to set the transparency for the face texture also.
script.Parent.Touched:Connect(function(hit)
local Head = hit.Parent:FindFirstChild("Head")
if Head then
Head.Transparency = 0
local Face = Head:FindFirstChild("face")
if Face then
Face.Transparency = 0
end
end
end)
Oh ok thanks, you’ve been really helpful.
EDIT: Ok one last thing it’s still making it nvisible and blocky, I assume I have to set the face texture to a transparency or something but I’m not entirely sure how to do that.
It looks like the material is set to glass. You would have to make it like this:
script.Parent.Touched:Connect(function(hit)
local Head = hit.Parent:FindFirstChild("Head")
if Head then
Head.Transparency = 0
local Face = Head:FindFirstChild("face")
if Face then
Face.Transparency = 0
end
Head.Material = Enum.Material.SmoothPlastic
end
end)
I don’t know about the blocky part. Mabey the mesh inside the head got deleted. Something has to be changing that.
Something’s obviously going on with the material, however I don’t think it’s glass. Parts with glass material when set to 100% transparency will not be visible, this looks more like forcefield.
Ok thanks, that made it a little better, altho the mesh is still gone. I don’t know how it would have gotten deleted, all I did was set it’s transparency to 1.