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

Why won't this script change the players WalkSpeed and JumpPower?

Asked by 5 years ago
local BindableEvent1 = game.Workspace:WaitForChild("PointsIncrease10")
local BindableEvent2 = game.Workspace:WaitForChild("PointsIncrease30")
game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new('Model')
    leaderstats.Name = 'leaderstats'
    leaderstats.Parent = player
    player.JumpPower = game.ReplicatedStorage.Points + 3
    player.WalkSpeed = game.ReplicatedStorage.Points + 3
    local JumpPower = Instance.new('IntValue')
    JumpPower.Value= 0
    JumpPower.Parent=leaderstats
    JumpPower.Name='Score'
    BindableEvent1.Event:Connect(function()
        JumpPower.Value= JumpPower.Value + 10
    BindableEvent2.Event:Connect(function()
        JumpPower.Value= JumpPower.Value + 30
    game.ReplicatedStorage.Points.Value = JumpPower.Value

    end)
    end)

    end)

Error message: Attempt to perform arithmetic on field 'Points' a userdata value

This script is meant to change the players stats depending on how many points they have.

1 answer

Log in to vote
1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

At this line

player.JumpPower = game.ReplicatedStorage.Points + 3

you are trying to add 3 to an instance. If Points is a Value object, then use its Value property

player.JumpPower = game.ReplicatedStorage.Points.Value + 3

same for the other line

Ad

Answer this question