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

SOLVED: Upvalue / Userdata value question?

Here is my code:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Speed = player.leaderstats:WaitForChild("Speed") or player.leaderstats.Speed

Speed.Changed:connect(function()
	character.Humanoid.Walkspeed = Speed + 1
end)

When I go into test and change the intvalue of speed on my player. it returns the error: Attempt to perform arithmetic on upvalue 'vitality' (a userdata value)

I have this script in starterplayer script.

the "speed" is a intvalue located in a leaderstats folder in the localplayer directory

I have tried adding wait() to see if it would catch it but nothing seems to work

what should I do?

1 answer

✓ Accepted answer

Your are trying to add a IntValue with a number, not the value of the IntValue itself, use IntValue.Value in order to get the IntValue’s value.

EDIT: IntValue*

1 comment

0

This! I tried it and it worked, thank-you!

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