Ok so, i hate working with childrens functions, i don't know why it doesn't work. I'm trying to make these beep blocks from Mario Galaxy.
(If you don't know how these blocks work, you should check this video https://youtu.be/EN4X7x4w65Q?t=3m9s)
But with this script, the blocks just do nothing at all.
Please, i need some help!
local g = script.Parent.Green local o = script.Parent.Orange local sound1 = script.Parent.Sound1 local sound2 = script.Parent.Sound2 function gr() if gr == true then script.Parent.Sound1:Play() for _, child in pairs(g:GetChildren()) do child.Reflectance = 0.4 wait(0.1) child.Reflectance = 0 end gr = false end end function gf() if gf == true then script.Parent.Sound2:Play() for _, child in pairs(g:GetChildren()) do child.Transparency = 1 child.CanCollide = false end for _, child in pairs(o:GetChildren()) do child.Transparency = 0 child.CanCollide = true end gf = false end end function ore() if ore == true then script.Parent.Sound1:Play() for _, child in pairs(o:GetChildren()) do child.Reflectance = 0.4 wait(0.1) child.Reflectance = 0 end ore = false end end function of() if of == true then script.Parent.Sound2:Play() for _, child in pairs(o:GetChildren()) do child.Transparency = 1 child.CanCollide = false end for _, child in pairs(g:GetChildren()) do child.Transparency = 0 child.CanCollide = true end of = false end end while true do wait(1.5) gr = true wait(0.7) gr = true wait(0.7) gr = true wait(0.7) gf = true wait(1.5) ore = true wait(0.7) ore = true wait(0.7) ore = true wait(0.7) of = true end
psst it's really easy to call functions.
local g = script.Parent.Green local o = script.Parent.Orange local sound1 = script.Parent.Sound1 local sound2 = script.Parent.Sound2 function gr() -- you set gr as the name for your function, you cannot reuse variable names -- if you want a debounce I can fix it for you. script.Parent.Sound1:Play() for _, child in pairs(g:GetChildren()) do child.Reflectance = 0.4 end wait(.1) for _, child in pairs(g:GetChildren()) do child.Reflectance = 0 end end function gf() script.Parent.Sound2:Play() for _, child in pairs(g:GetChildren()) do child.Transparency = 1 child.CanCollide = false end wait(.1) for _, child in pairs(o:GetChildren()) do child.Transparency = 0 child.CanCollide = true end end function ore() script.Parent.Sound1:Play() for _, child in pairs(o:GetChildren()) do child.Reflectance = 0.4 end wait(.1) for _, child in pairs(o:GetChildren()) do child.Reflectance = 0 end end function of() script.Parent.Sound2:Play() for _, child in pairs(o:GetChildren()) do child.Transparency = 1 child.CanCollide = false end wait(.1) for _, child in pairs(g:GetChildren()) do child.Transparency = 0 child.CanCollide = true end end while true do wait(1.5) gr() -- that's how you run a function wait(0.7) gr() wait(0.7) gr() wait(0.7) gf() wait(1.5) ore() wait(0.7) ore() wait(0.7) ore() wait(0.7) of() end