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

How could i fix Attempt to connect failed: Passed value is not a function?

My script is supposed to display +, if there are multiple eliminations and 0 deaths, and - for when there are 0 eliminations and multiple deaths. My script is

local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local elims = leaderstats:WaitForChild("Eliminations")
local deaths = leaderstats:WaitForChild("deaths")
local statisticsMenu = player.PlayerGui:WaitForChild("statistics")
elims.Changed:Connect()
if leaderstats.Eliminations.Value >= 0 and
	leaderstats.deaths.Value == 0 then
	player.PlayerGui.statistics.Frame.kdRatioNumber.Text = "+"
deaths.Changed:Connect()
	if leaderstats.Eliminations.Value == 0 and
		leaderstats.deaths.Value >= 0 then
			player.PlayerGui.statistics.Frame.kdRatioNumber.Text = "-"
	end
	end

2 answers

✓ Accepted answer

Shortly, you did ':Connect()' with the argument empty. There must be argument of 'function()' or you can call a function. Try to fix that; hope it was useful. Message me for further questions!

To make the .Changed event work, you need to do :Connect(function() not :Connect(), also, you made some mistakes on if statements. So your script will be like this:

local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local elims = leaderstats:WaitForChild("Eliminations")
local deaths = leaderstats:WaitForChild("deaths")
local statisticsMenu = player.PlayerGui:WaitForChild("statistics")
elims.Changed:Connect(function()
if leaderstats.Eliminations.Value >= 0 and
    if leaderstats.deaths.Value == 0 then
    player.PlayerGui.statistics.Frame.kdRatioNumber.Text = "+"
	end
	end
end)
deaths.Changed:Connect(function()
    if leaderstats.Eliminations.Value == 0 and
        if leaderstats.deaths.Value >= 0 then
            player.PlayerGui.statistics.Frame.kdRatioNumber.Text = "-"
	end
	end
end)

I hope this helped you! edit: Forgot to make :Connect(function() on deaths.Changed

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