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 6 years ago
01local BindableEvent1 = game.Workspace:WaitForChild("PointsIncrease10")
02local BindableEvent2 = game.Workspace:WaitForChild("PointsIncrease30")
03game.Players.PlayerAdded:Connect(function(player)
04    local leaderstats = Instance.new('Model')
05    leaderstats.Name = 'leaderstats'
06    leaderstats.Parent = player
07    player.JumpPower = game.ReplicatedStorage.Points + 3
08    player.WalkSpeed = game.ReplicatedStorage.Points + 3
09    local JumpPower = Instance.new('IntValue')
10    JumpPower.Value= 0
11    JumpPower.Parent=leaderstats
12    JumpPower.Name='Score'
13    BindableEvent1.Event:Connect(function()
14        JumpPower.Value= JumpPower.Value + 10
15    BindableEvent2.Event:Connect(function()
View all 22 lines...

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
6 years ago

At this line

1player.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

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

same for the other line

Ad

Answer this question