Hello, I am new at scripting, and I decided to take the devhub course on a fading trap. However, I realized that with r15, players could spam jump across without triggering the response. To fix this, I removed the CanCollide from the script, set the CanCollide to false, and inserted an invisible part underneath. My idea was to make the invisible part’s CanCollide false when the fading part’s transparency equalled 1. I have already figured out a working script, but it only fired when the fading part was touched, which created some minor issues. I then did the following script:
local fadePart = script.Parent.Parent.fadePlatform
local fallPart = script.Parent
while true do
if fadePart.Transparency == 1 then
fallPart.CanCollide = false
else
fallPart.CanCollide = true
end
end
However, it is not working. (The local variables are working, and local fadePart = script.Parent.Parent.fadePlatform works)
Is there an error in my code?
Here’s a screenshot of the part:
I would go back to this script, can you post the code and tell us what the issues were with it? Using Touched for a trap is definitely a better route to go than a while loop.
Thank you everyone for your responses and help! I ended up solving this by combining the script of the invisible part with the script of the fading part:
local platform = script.Parent
local fallPlatform = script.Parent.Parent.notfade
local isTouched = false
local function fade()
if not isTouched then
isTouched = true
for count = 1, 10 do
platform.Transparency = count / 10
wait(0.1)
end
fallPlatform.CanCollide = false
wait(3)
fallPlatform.CanCollide = true
platform.Transparency = 0
isTouched = false
end
end
platform.Touched:Connect(fade)