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 5 years ago
Edited 5 years ago

So whenever i run the game on studio it says:

115: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:

01function Refresh()
02 
03    for i,v in pairs(Items) do
04 
05        if v.Length < 1 then
06            print("Test")
07        end
08 
09    end
10 
11 
12end
13 
14Slots[1].MouseButton1Down:Connect(Refresh())
0
What is this suppose to do? Just2Terrify 566 — 5y

2 answers

Log in to vote
0
Answered by 5 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..

01function Refresh()
02 
03    for i,v in pairs(Items) do
04 
05        if v.Length < 1 then
06            print("Test")
07        wait(0.5)
08        end
09 
10    end
11 
12 
13end
14 
15Slots[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 — 5y
Ad
Log in to vote
0
Answered by 5 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:

01function Refresh()
02 
03    for i,v in pairs(Items) do
04 
05        if v.Length < 1 then
06            print("Test")
07        end
08 
09    end
10 
11 
12end
13 
14Slots[1].MouseButton1Down:Connect(Refresh)

Hope this helps!

Answer this question