Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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())

1 comment

0

What is this suppose to do?

2 answers

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())

1 comment

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.

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.