Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.