this code will go into a block that falls when a player steps on it, I also want the transparency to go down after it unanchores.
1 | repeat part.Transparency - 20 |
2 | until part.Transparency = 0 |
and this code makes it fall, but when I add the other code it doesn't work.
01 | local part = script.Parent |
02 |
03 | local function onPartTouched(otherPart) |
04 |
05 | local partParent = otherPart.Parent |
06 | local humanoid = partParent:FindFirstChildWhichIsA( "Humanoid" ) |
07 | if humanoid then |
08 | wait( 0.1 ) -- I can adjust this |
09 | part.Anchored = false |
10 | --repeat part.Transparency - 20 |
11 | --until part.Transparency = 0 |
12 | end |
13 | end |
14 |
15 | part.Touched:Connect(onPartTouched) |
Use for i loops, they are mean't to do things like that
01 | local function onPartTouched(Part) |
02 | for i = 1 , 0 ,- 0.1 do |
03 | Part.Transparency = i |
04 | wait() |
05 | end |
06 | end |
07 |
08 | local part = script.Parent |
09 |
10 | local function onPartTouched(otherPart) |
11 | local partParent = otherPart.Parent |
12 | local humanoid = partParent:FindFirstChildWhichIsA( "Humanoid" ) |
13 | if humanoid then |
14 | wait( 0.1 ) -- I can adjust this |
15 | part.Anchored = false |
16 | OnPartTouched(part) |
17 | end |
18 | end |
19 |
20 | part.Touched:Connect(onPartTouched) |
I hope this helps.