This is my output:
08:45:57.971 -** Attempt to connect failed: Passed value is not a function** 08:45:57.974 - Script 'Workspace.Model.Muffin Button.Script', Line 55 08:45:57.975 - Stack End
After I click the top button, I get:
08:47:12.682 -** attempt to call a nil value** 08:47:12.684 - Disconnected event because of exception
So I've looked at the function name and calling it, I can't find the issue.
Please help/
local platform = script.Parent.Parent.Platform -- this is the Part we will move local newPos = platform.Position + Vector3.new(0,20.09,0) -- the position the Part will go to local Time = 5 -- the time that the script will take to move the part local Increment = 0.1 -- the Part will move 0.5 studs each time it moves local Debounce = false up = false local Diff = newPos - platform.Position -- the difference between the two positions local Mag = Diff.magnitude -- the distance between the two parts local Direction = CFrame.new(platform.Position, newPos).lookVector local DownDirection = CFrame.new(platform.Position, newPos).lookVector function MovePart() if up == true then return false end wait(2) for n = 0, Mag, Increment do platform.CFrame = platform.CFrame +(Direction * Increment) wait( (Time/Mag) * Increment ) up = true end wait(3) if up == true then for n = 0, Mag, Increment do platform.CFrame = platform.CFrame -(Direction * Increment) wait( (Time/Mag) * Increment ) up = false function MovePart2() if up == true then return false end for n = 0, Mag, Increment do platform.CFrame = platform.CFrame +(Direction * Increment) wait( (Time/Mag) * Increment ) up = true end wait(3) if up == true then for n = 0, Mag, Increment do platform.CFrame = platform.CFrame -(Direction * Increment) wait( (Time/Mag) * Increment ) up = false end end end end end end script.Parent.ClickDetector.MouseClick:connect(MovePart) script.Parent.Parent.TopButton.ClickDetector.MouseClick:connect(MovePart2)
This is a situation where proper tabbing is useful. Your second function, MovePart2
, is actually defined inside of MovePart
:
function MovePart() if up == true then return false end wait(2) for n = 0, Mag, Increment do platform.CFrame = platform.CFrame +(Direction * Increment) wait( (Time/Mag) * Increment ) up = true end wait(3) if up == true then for n = 0, Mag, Increment do platform.CFrame = platform.CFrame -(Direction * Increment) wait( (Time/Mag) * Increment ) up = false function MovePart2() if up == true then return false end for n = 0, Mag, Increment do platform.CFrame = platform.CFrame +(Direction * Increment) wait( (Time/Mag) * Increment ) up = true end wait(3) if up == true then for n = 0, Mag, Increment do platform.CFrame = platform.CFrame -(Direction * Increment) wait( (Time/Mag) * Increment ) up = false end end end end end end
To fix this, you need to move the last 3 end
s to line 28. And then un-tab MovePart2 three times.