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!
2 comments
bro idk why the the normal text is in lua code please forgive me i have no idea what went wrong
thank you for your answer, i thought about doing it this way, but the problem is that I have about 400 of these platforms, so I cant reference them, even if i named them like 'platform 1' 'platform 2' etc, I would have to change the code for all 400 of the invisible pieces so that each one corresponds to a part that you can see. Also it would be smart to put the transparency in a loop :)