Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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

01local player = game.Players.LocalPlayer
02local leaderstats = player:WaitForChild("leaderstats")
03local elims = leaderstats:WaitForChild("Eliminations")
04local deaths = leaderstats:WaitForChild("deaths")
05local statisticsMenu = player.PlayerGui:WaitForChild("statistics")
06elims.Changed:Connect()
07if leaderstats.Eliminations.Value >= 0 and
08    leaderstats.deaths.Value == 0 then
09    player.PlayerGui.statistics.Frame.kdRatioNumber.Text = "+"
10deaths.Changed:Connect()
11    if leaderstats.Eliminations.Value == 0 and
12        leaderstats.deaths.Value >= 0 then
13            player.PlayerGui.statistics.Frame.kdRatioNumber.Text = "-"
14    end
15    end

2 answers

Log in to vote
1
Answered by
XDvvvDX 186
4 years ago
Edited 4 years ago

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!

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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:

01local player = game.Players.LocalPlayer
02local leaderstats = player:WaitForChild("leaderstats")
03local elims = leaderstats:WaitForChild("Eliminations")
04local deaths = leaderstats:WaitForChild("deaths")
05local statisticsMenu = player.PlayerGui:WaitForChild("statistics")
06elims.Changed:Connect(function()
07if leaderstats.Eliminations.Value >= 0 and
08    if leaderstats.deaths.Value == 0 then
09    player.PlayerGui.statistics.Frame.kdRatioNumber.Text = "+"
10    end
11    end
12end)
13deaths.Changed:Connect(function()
14    if leaderstats.Eliminations.Value == 0 and
15        if leaderstats.deaths.Value >= 0 then
16            player.PlayerGui.statistics.Frame.kdRatioNumber.Text = "-"
17    end
18    end
19end)

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

Answer this question