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

Help With Userdata Value Issues?

I need a string value in a player to constantly this part's position. This isn't the following script, cuz the rest of it works fine. In this line it says " attempt to concatenate field 'Position' (a userdata value)" and then doesn't change the value. Any help?

Player[script.Parent.ItemNumberPos.Value].Value = ""..script.Parent.PrimaryPart.Position..""

2 comments

0

Vector3 values cannot be printed. Try printing .Position.X,.Position.Y,.Position.Z instead

0

It's working now. You should have said that in an answer though so I could give you a point of rep for that.

1 answer

✓ Accepted answer

In order to concatenate Position, or a Vector3, you would need to use the tostring() function. all tostring() does is makes numbers, userdatas, etc into a string so it can be concatenated or printed.

To fix your code,

Player[script.Parent.ItemNumberPos.Value].Value = tostring(script.Parent.PrimaryPart.Position)

I hope you've learned from this, and have an excellent day!

2 comments

1

Another way to do this is to change Player[script.Parent.ItemNumberPos] to a Vector3Value, and not a StringValue.

2

Thanks, man!

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