I'm attempting to code a disappearing platform with multiple parts. Once the player steps on the platform, the entire thing should gradually disappear and reappear shortly after. The script is also meant to apply to every model in workspace by the name of "Platform". (no quotes)
Once a platform is stepped on, no errors are shown yet nothing happens.
Here is my script:
num = 40
local platform = Instance.new("Platform",game.Workspace)
for _, instance pairs(workspace:GetChildren()) do
if instance.Name == 'Platform' then
for _, instance_2 in pairs(instance:GetDescendants()) do
function onTouched(hit)
for i = 1, num do
instance.Transparency = 0.5+1/num/2
instance.CanCollide = false
wait()
end
for i = 1, num do
instance.Transparency = 1 - i/num/2
instance.CanCollide = true
wait()
end
instance.Touched:connect(onTouched)
end
end
end
Also I have extremely little knowledge of Lua, so you may have to explain this to me in caveman terms.

3 comments
No, for some reason nothing still happens. Is it because I have the script in workspace?
Nevermind! I figured it out. The platform models are inside of a folder, that's why the script wasn't running. Thank you for your help!
No problem!