function not creating object

Okay, so I’m trying to make a value inside the player object go up when they click an object, and to do that, I need to create said value. The following is the script I had so far. It was in starterplayerscripts.

r = script.Parent
h ="IntValue")
h.Parent =  r
h.Name = "AsbestosRemoved"

h, or AsbestosRemoved, is not existent within the player, which means that all of the scripts that rely on it are broken as a result.

I’ve tried relocating the script and moving it to startercharacterscripts and using getplayerfromcharacter. Nothing so far has worked.

1 Like

So you’re just trying to parent this IntValue to the player, character, main script, or what?

Is this script inside the player you want to parent the IntValue to? Otherwise it’s creating the IntValue in the wrong place.

1 Like

If it’s in StarterPlayerScripts, then the value will be under Player > PlayerScripts

1 Like

So changing r to script.parent.parent will work?

1 Like

Yes, I want to parent it to the player.

1 Like

I’m looking around for it and it isn’t anywhere in studio explorer

1 Like

are you sure the code is even executing? Add a print statement at the end of that code and see if it prints

1 Like

It isn’t executing. It’s in a normal script, might that be the problem?

1 Like

yeah that’d the the problem
(character limit)

1 Like

How do I fix this “Character Limit” issue? What even is it?

1 Like

I was trying to bypass the devforum’s 30-character limit when replying, sorry for the confusion


I need the variable to exist on the server side, how do I do this without using a normal script?

1 Like

Local scripts are client sided, normal blue scripts are server sided.

Okay, but how do I make the variable exist on the server, while still being a child of the player?

Avoid bypassing the character limit, as it’s wrong.

Non-Replicated Instances

If the value being sent is only visible to the sender, nil will be passed instead of the value. For example, if a server tries to pass a descendant of ServerStorage , the client listening to the event will see a nil value because that object isn’t replicated to the client.

Similarly, if a client creates a part and tries to pass it to the server, the server will see a nil value because the part isn’t replicated to the server.

Taken from the following page:

Remote Functions and Events | parameter-limitations (

I understand why it doesn’t work. I just want to know how to make it work.

Or maybe that’s going off-topic and I should start a new thread

If I understand correctly, you just want to parent a value to the player on the server? If so, you can just do that. No LocalScripts necessary.

Well, I kind of want each player to have their own value.

Are there any threads that might help me?

function addValueToPlayer(targetPlayer)
	local val ="IntValue");
	val.Name = "AsbestosRemoved";
	val.Parent = targetPlayer;

game:GetService("Players").PlayerAdded:Connect(addValueToPlayer); --Adds this value to any player who joins