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

I am getting a connect failed error. Can someone explain why this code not working?

Asked by 4 years ago
Edited 4 years ago

So whenever i run the game on studio it says:

15:32:57.254 - Attempt to connect failed: Passed value is not a function

I have looked online and people have been saying it has to be Before the connect, Which in my case it is. Here is the code:

function Refresh()

    for i,v in pairs(Items) do

        if v.Length < 1 then
            print("Test")
        end 

    end


end

Slots[1].MouseButton1Down:Connect(Refresh())
0
What is this suppose to do? Just2Terrify 566 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

I'm not entirely sure what this script is suppose to be doing other than printing something but try adding a wait(0.5) command. Like this..

function Refresh()

    for i,v in pairs(Items) do

        if v.Length < 1 then
            print("Test")
        wait(0.5)
        end 

    end


end

Slots[1].MouseButton1Down:Connect(Refresh())
0
It is not working and the script is meant to check if something is in a inventory slot. I put the print just to check if it works. FallenReju 3 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Hello! Looking at the script made me think that Slots[1].MouseButton1Down:Connect(Refresh()) is wrong. I think it should be Slots[1].MouseButton1Down:Connect(Refresh)

Finished code:

function Refresh()

    for i,v in pairs(Items) do

        if v.Length < 1 then
            print("Test")
        end 

    end


end

Slots[1].MouseButton1Down:Connect(Refresh)

Hope this helps!

Answer this question