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.
This here should fix your errors, let me know if you're still having any errors.
local model = game.Workspace.DissapearingBricks -- change this to the model/folder that holds your dissapearing bricks local num = 40 for _, brick in pairs(model:GetChildren()) do -- looping through every part in the model specified brick.Touched:Connect(function(hit) -- calling the touch event for every brick/part in the model if hit.Parent:FindFirstChild("Humanoid") then -- checking if a player touched the brick for i = 1, num do brick.Transparency = 0.5+1/num/2 brick.CanCollide = false wait() end for i = 1, num do brick.Transparency = 1 - i/num/2 brick.CanCollide = true wait() end end end) end