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

Why does it always say Attempt to connect failed: Passed value is not a function?

I want to make a code where if a player clicks the block he will give 1 point to the testValue then changes the gui text into Points:(testValue) accurately

local testPart = script.Parent
local testValue = testPart.testValue.Value
local testGui = game.StarterGui.ScreenGui.TextLabel
availability = true
-------------------------------------------------
local function PointsSystem(num)
		availability = false
	local value = num + 1
		availability = true
	return value
end

local value = PointsSystem(testValue)

local function afterClick()
	testGui.Text = ("Points:".. " ".. testValue)
end


testPart.ClickDetector.MouseClick:Connect(afterClick)
testPart.ClickDetector.MouseClick:Connect(value)

------------------------------------------------------

1 answer

local value = PointsSystem(testValue)

This will run the "PointSystem" function and assign whatever value "PointSystem" returns into the variable "Value", it doesnt assign the function into the variable

Which mean

testPart.ClickDetector.MouseClick:Connect(value)

That line wont work because "value" is an int, not a function,

Also why do these on multiple function? You could just add the point, assign it, and change the text all in 1 function, that "Availability" variable serve no purpose at all, so just delete it

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