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.
repeat part.Transparency - 20 until part.Transparency = 0
and this code makes it fall, but when I add the other code it doesn't work.
local part = script.Parent local function onPartTouched(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") if humanoid then wait(0.1) -- I can adjust this part.Anchored = false --repeat part.Transparency - 20 --until part.Transparency = 0 end end part.Touched:Connect(onPartTouched)
Use for i loops, they are mean't to do things like that
local function onPartTouched(Part) for i = 1,0,-0.1 do Part.Transparency = i wait() end end local part = script.Parent local function onPartTouched(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") if humanoid then wait(0.1) -- I can adjust this part.Anchored = false OnPartTouched(part) end end part.Touched:Connect(onPartTouched)
I hope this helps.