I am making a game with disappearing platforms, that fade to transparent and then turn canCollide off (after a second's delay), when a player touches them. The problem is, the onTouched() event does not seem to work when jumping, or if a player falls from above onto the intersection between 2 or more parts.
Because these are platforms that a player stands on, I cannot use the normal advice I find for kill boxes with the same problem, which is to turn canCollide off. I also tried some other advice I found, which is to make a transparent and untouchable part that has the functionality of the part you wanted, and then use the original part as just for the look you wanted. You were supposed to place the transparent "functional" part slightly above the original part. Then I realized that when I was all finished, it turned out that i had some transparent parts turning transparent and then dissappearing, and my original parts were still there. Again, it was advice made for kill boxes where OnTouched wasn't working, not something you need to stand on.
I am willing to show code snippets if it makes any difference.
Hello!
I think you're trying to make a part disappear (well with transparency and cancollide) when a player goes on it. If I'm wrong, tell me. So this is the code you would use
(you would put this script in the part you're using)
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local function FadeAway() script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(0.05) end FadeAway() script.Parent.CanCollide = false end end)
Or, another thing that I think that you're trying to do is where it doesn't run when you touch the part. I know what you're talking about, where players can just hold the spacebar and evade the script from running. I get it, it's pretty annoying. Fortunately, this is a simple fix. Instead of using script.Parent, you're gonna reference the part the boring through game.Workspace. To start off, make a copy of the part and set the transparency to 1, and cancollide to true and put it 1 stud above the part you're trying to make fade away. Then in that script, you're going to insert this script
local Part = game.Workspace.YourPartName Part.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.Transparency = Part.Transparency + 0.1 wait(0.05) Part.CanCollide = false end end)
Put the name of the part you're trying to make disappear in "YourPartName" Hopefully this works!