Script can't access existing value

Hello, I’m making a football game that lets you change the power of shooting the ball.

I created a value with power set as 10 as default. In a localscript.

But when I try to access it with a serverscript, it says it can’t find it, while when i type the same line of code in the ‘Run a command’ bar it does work. I can see that it is in my character and it seems to work fine when the value is in workspace. Could anyone help me, I can provide the whole script if needed.

Thanks,

DanielosthebestYTalt

Is it perhaps because of the kind of value? All I need is numbers ranging from 0 - 200.

I’ve tried number and intvalues.

Depends on the script error, does it say that the value is nil?
An event might run before the game is loaded, is there a script error in the output?

Yes, when I go into current client mode, it doesn’t show the value, while I used a script to put it in.

The error message is:


Value is not a valid member of Model “Workspace.Danielosthebest”

Any created Instance on the client stays there and will not be replicated to others/server.

1 Like

Yes, I just realized that now you said it. How do I create a value in the players character (easiest to access) without using a localscript?

So I can’t use game.player.LocalPlayer.Character

Put it in startercharacterscripts

Yeah, but you can get a specific player and its character from the server using another approach.

Local player is only accessible in local scripts, the value only exists on the client.

I’ll try, but where to put the serverscript? ServerScriptService?

startercharacterscripts in StarterPlayer

Then try to reference it in your script.

so I could try the following?:

local power = Instance.new("IntValue")

power.Parent = game.StarterPlayer.StarterCharacterScripts

If there are no other issues it should resolve the problem