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

Whats wrong in line 6?

Asked by 8 years ago

Got this error message

23:58:47.299 - Players.Player.PlayerGui.KnifeScript:6: attempt to index field 'Value' (a number value) 23:58:47.302 - Stack Begin 23:58:47.303 - Script 'Players.Player.PlayerGui.KnifeScript', Line 6 23:58:47.303 - Stack End

For this script:

while wait() do
    player = game.Players.LocalPlayer
    leaderstats = player:WaitForChild("leaderstats")
    Spree = leaderstats:WaitForChild("Spree")
    SHS = leaderstats:WaitForChild("Spree HS")
    Spree.Value.Changed:connect(function(prop)
        if Spree.Value >= SHS.Value then
            SHS.Value = Spree.Value
        end
    end)
end
2
Properties do not have events, all you would need to do is remove .Value from line 6 then the script will know that the object has events and fire if the property has changed. M39a9am3R 3210 — 8y
0
Great. Thanks! fahmisack123 385 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Try this as a fix!

while wait() do
    player = game.Players.LocalPlayer
    leaderstats = player:WaitForChild("leaderstats")
    Spree = leaderstats:WaitForChild("Spree")
    SHS = leaderstats:WaitForChild("Spree HS")
    Spree.Changed:connect(function(prop)
    if prop == "Value" then
            if Spree.Value >= SHS.Value then
                SHS.Value = Spree.Value
            end
    end
    end)
end

Ad

Answer this question