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

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

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:

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

Answer this question