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

Attempt to Connect: Passed value is not a function?

Hello, I am writing a Reader Script[local] to apply information from a StringValue called Currentinfo, it's basically a "StatusBar". I have done quite a bit of Debugging myself, I've made sure the ServerScript is doing it's part to apply the String to the Currentinfo value, which it works fine. It's more of the LocalScript that isn't working. I was originally using the .Changed event, which wasn't working properly, was also refusing to Change the TextLable (Header) to the preferred String requested by the ServerScript. I decided to switch to GetPropertyChangedSignal. That seemed to fix most of my issues, only now I have this. 19:50:44.743 - Attempt to connect failed: Passed value is not a function 19:50:44.745 - Stack Begin 19:50:44.746 - Script 'Players.cinemakiller.PlayerGui.BaseGuis.BaseHeader.Header.Reader', Line 9 19:50:44.748 - Stack End 19:50:44.891 - attempt to call a nil value 'Attempt to call a nil value' - This has not origin link, so I can't tell if it's actually apart of it or not; could be from my other running Script, it's not connected to this issue. I can resolve it myself if so.

Heres the Code:

local Currentinfo = game:GetService("ReplicatedStorage"):FindFirstChild("Other").Currentinfo
local Player = game:GetService("Players").LocalPlayer; local Header = Player:FindFirstChild("PlayerGui").BaseGuis.BaseHeader.Header 
local function SetHeadder()
    if Currentinfo then
        local Header = Player:FindFirstChild("PlayerGui").BaseGuis.BaseHeader.Header; if Header then print("Header") end
        Header.Text = Currentinfo.Value
    end;
end;
Currentinfo:GetPropertyChangedSignal("Value"):Connect(SetHeadder())

Thank you

1 answer

✓ Accepted answer

In your function connection, you're essentially trying to call the SetHeadder function, which is wrong, so just remove the set of parentheses.

	Currentinfo:GetPropertyChangedSignal("Value"):Connect(SetHeadder)

Also, you should only use :FindFirstChild() like so:

local part = workspace:FindFirstChild("Part")

if part then
  --do code
end

if you're simply doing if workspace:FindFirstChild("Part").OtherPart then, you're not allowing the method to perform it's job correctly. In the above example, if "Part" is nonexistent, the script will error. If you follow the logic in the previous code block, it works as intended though.

7 comments

0

I write my Code in a weird way, I use Semicolons a lot too. It's just me transitioning from another language, I couldn't quite understand your answer, could you rephrase?

0

just change the last line to Currentinfo:GetPropertyChangedSignal("Value"):Connect(SetHeadder)

0

That's the same thing

0

Is it not?

0

its not, bc you call a function with FunctionName(), but you dont call it in the connection

0

Oh....... I've been Scripting for four years in Lua... I can't believe I had been so blind, of course. Connect event autoreads the Variable with Parentheses......... I am working on a large project, I am pretty tried after working so hard each day. I'm writing a CoreScript, thanks for snapping me out of it!

0

yw

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