Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can someone help me fix this output error?

Asked by
Xoqex 75
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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)

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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 ends to line 28. And then un-tab MovePart2 three times.

1
Thanks, you really helped me out. I'm still learning and never realized formatting was this important. I also figured out how to get rid of all the bugs while writing this, so thanks again. Xoqex 75 — 10y
Ad

Answer this question