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

(?) "Not a valid member of model"

local Chakra = Instance.new('NumberValue',game.Players.LocalPlayer.Character)
Chakra.Value = 1
Chakra.Name = 'Chakra'

This is when they use the tool it happens

local Chakra = Player.Character.Chakra
Chakra.Value = Chakra.Value - .2 

I tried using a remoteevent to fire the server but I couldn't make it work.

Here is a vid of the problem occurring https://gyazo.com/0f72c8f05417d25284f8b1122e5a9592

1 answer

✓ Accepted answer

Outlook on your problem

I believe this is primarily because the Script is requesting access to something that is null, at the time, I presume you're using a ServerScript, therefore this will mean it'll run as soon as the Server is available. Which is when you run your Game. LocalScripts will run when the Client is available, which is slightly a millisecond after I'm correct. Assets are last to load. Since these Scripts run so quickly they may not be available yet. Simply yielding the Script until the requested asset is prepared, constructed, and accessible. Since this is a Child of Character, you can successfully accomplish this by calling the :WaitForChild(handle) method on the Object.

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Part = Character:WaitForChild("myPart")

Hope this helps! If so don't forget to accept and optionally upvote!

Extra reminders

Instance.new() function’s secondary argument was deprecated, meaning you can’t properly set the parent anymore without encountering issues most attempts. Though this is only for passing the Parent in the function’s parentheses so ultimately you can swerve around this by setting the Parent a line below.

7 comments

0

Alternatively if non of the solve your problem, just apply :WaitForChild(Object) to Character.

0

that is what I was gonna suggest.

0

or :FindFirstChild(Object)

0

btw this has nothing to do with "is not a valid member of 'Model'

0

I could, generally Scripts run aster than assets load, so therefore it could ask for something too fast

0

I'll edit my answer

0

There, I had two approaches, I wrote this late last night, should've gone with this one 

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