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

Attempt to connect failed: Passed value is not a function?

Asked by 5 years ago
player = game.Players.LocalPlayer
playerinWorkspace = player.Character.Name

function addStat(x)
    if player.Stats.Value > 0 then
        if x == "Strength" then
            player.Stats.Strength.Value = player.Stats.Strength.Value + 1
            script.Parent.Parent.Information.STR.Text = "STR: " .. tostring(player.Stats.Strength.Value)
        elseif x == "Agility" then
            player.Stats.Agility.Value = player.Stats.Agility.Value + 1
            script.Parent.Parent.Information.AGI.Text = "AGI: " .. tostring(player.Stats.Agility.Value)
        elseif x == "Intelligence" then
            player.Stats.Intelligence.Value = player.Stats.Intelligence.Value + 1
            script.Parent.Parent.Information.INT.Text = "INT: " .. tostring(player.Stats.Intelligence.Value)
        elseif x == "Defense" then
            player.Stats.Defense.Value = player.Stats.Defense.Value + 1
            script.Parent.Parent.Information.DEF.Text = "DEF: " .. tostring(player.Stats.Defense.Value)
        elseif x == "Vitality" then
            player.Stats.Vitality.Value = player.Stats.Vitality.Value + 1
            script.Parent.Parent.Information.VIT.Text = "VIT: " .. tostring(player.Stats.Vitality.Value)
        elseif x == "Dexterity" then
            player.Stats.Dexterity.Value = player.Stats.Dexterity.Value + 1
            script.Parent.Parent.Information.DEX.Text = "DEX: " .. tostring(player.Stats.Dexterity.Value)
        end
    end
    script.Parent.statPoints.Text = "Status Points: " .. tostring(player.Stats.Value)
end

function onStart()
    script.Parent.statPoints.Text = "Status Points: " .. tostring(player.Stats.Value)
    script.Parent.Parent.Information.STR.Text = "STR: " .. tostring(player.Stats.Strength.Value)
    script.Parent.Parent.Information.AGI.Text = "AGI: " .. tostring(player.Stats.Agility.Value)
    script.Parent.Parent.Information.INT.Text = "INT: " .. tostring(player.Stats.Intelligence.Value)
    script.Parent.Parent.Information.DEF.Text = "DEF: " .. tostring(player.Stats.Defense.Value)
    script.Parent.Parent.Information.VIT.Text = "VIT: " .. tostring(player.Stats.Vitality.Value)
    script.Parent.Parent.Information.DEX.Text = "DEX: " .. tostring(player.Stats.Dexterity.Value)
end

script.Parent.addStr.MouseButton1Click:connect(addStat("Strength"))
script.Parent.addAgi.MouseButton1Click:connect(addStat("Agility"))
script.Parent.addInt.MouseButton1Click:connect(addStat("Intelligence"))
script.Parent.addDef.MouseButton1Click:connect(addStat("Defense"))
script.Parent.addVit.MouseButton1Click:connect(addStat("Vitality"))
script.Parent.addDex.MouseButton1Click:connect(addStat("Dexterity"))
player.CharacterAdded:connect(onStart)

Parameters doesn't work as intended?

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

For lines 39 to 44, you should connect the events in an anonymous function like this:

script.Parent.addStr.MouseButton1Click:Connect(function()
        addStat('Strength')
end)

script.Parent.addAgi.MouseButton1Click:Connect(function()
        addStat('Agility')
end)

script.Parent.addInt.MouseButton1Click:Connect(function()
        addStat('Intelligence')
end)

script.Parent.addDef.MouseButton1Click:Connect(function()
       addStat('Defense')
end)

script.Parent.addVit.MouseButton1Click:Connect(function()
        addStat('Vitality')
end)

script.Parent.addDex.MouseButton1Click:Connect(function()
        addStat('Dexterity')
end)
0
Thanks :D, sorry for the noobish question, just started learning roughly a month ago xD xxXTimeXxx 101 — 5y
Ad

Answer this question