Hello guys !
So I’m trying to make a script that when a platform touch a part, the platform became Invisible.
For this, I made a bool value, “Visibility”. When it is true, the platform is visible and when it’s false, it’s invisible. (This work)
For the part touched it doesn’t work, here is the script:
script.Parent.Touched:Connect(function(hit)
if hit.Name == "MovingPart" then
script.Parent.Parent.MovingPart:WaitForChild("Visibility").Value = false
end
end)
There are two possible reason why this wouldn’t work one being that you aren’t changing MovingPart.Transparency when the visibility is changed, and the second being that both parts are non-collidable, thus the touched event never firing.
Addition: you can just set hit.Visibility.Value to false, rather than getting hit via script.Parent.Parent.MovingPart Even better, you can directly modify the Part’s Transparency, via a simply ternary operator
Part.Transparency = (Part.Transparency == 0 and 1 or 0)
Yea, simple syntax error on the last “end”, should be end). recommend using the Output and script analysis windows. These tools would have answered your question. Both windows can be enabled in the “View” menu.
I use these tools. This is only because I write this on my smartphone and I don’t have the script with me (I remember I put “end)” but not on this topic )
Did you even read my topic, it’s said that it’s a Visibilty BOOL VALUE, BOOL, like true or false.
This value change the transparency and the can collide of a model
I put two print() to see where it doesn’t work
script.Parent.Touched:Connect(function(hit)
print(1)
if hit.Name == “MovingPart” then
print(2)
script.Parent.Parent.MovingPart:WaitForChild(“Visibility”).Value = false
end
end)
There is two MovingPart, MovingPart (Model) and MovingPart(PrimaryPart) it move with a SetPrimaryCFrame(). I want to make when the MovingPart(PrimaryPart) touch a part the MovingPart(Model) became Invisible and NoCanCollide and vice versa