Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

Why is this giving me a "syntax" error?

Asked by 9 years ago

I am trying to make a custom third person health bar (other people see it) I have it so that it makes the local players head the Adornee, which would then put the billboard gui above the players head... But it's saying that "player is not a valid member of Workspace"

Local player = game.Players.LocalPlayer:GetFullName()

script.Parent.Adornee = script.Parent.Parent.Parent.Parent.Parent.Workspace.player.Head

Please help Thank you!

0
Try game.Workspace.player.Head Discern 1007 — 9y
0
For starters your 1st line, your variable can't have a space in it... tanzane 100 — 9y
0
Dafuq you talking about tanzane, nothing wrong with his first variable Bman8765 270 — 9y
0
For starters it's local player, if you don't know what your talking about, don't comment yogipanda123 120 — 9y
View all comments (16 more)
0
@Discern- I tried that just now, it gave the same error! yogipanda123 120 — 9y
0
Omg, no I mean if you're going to do a Local Keyword. Make sure it isn't cap'd. Stop acting like I was wrong... tanzane 100 — 9y
0
Except you were, that wasn't even the error yogipanda123 120 — 9y
0
It WOULD of been if I hadn't told you tanzane 100 — 9y
0
Except that it WASNT even BEFORE you posted yogipanda123 120 — 9y
0
Where is the script in your game? tanzane 100 — 9y
0
It is in the player's gui yogipanda123 120 — 9y
0
But it is originally in the starter gui yogipanda123 120 — 9y
0
Is this a local script? tanzane 100 — 9y
0
No, wait, then do script.Parent.Parent.Character.Head tanzane 100 — 9y
0
I did that, but now nothing happens yogipanda123 120 — 9y
0
Not even an error yogipanda123 120 — 9y
0
What is the whole line of text? tanzane 100 — 9y
0
I don't understand what you mean, of course it's text, what else could it be? yogipanda123 120 — 9y
0
Show me the WHOLE script tanzane 100 — 9y
0
That is the entire script yogipanda123 120 — 9y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

That is not a syntax error.

A syntax error is when you are syntactically invalid -- that is, it doesn't care what you wrote, the "grammar" of it is wrong.


The error you're getting is a run time error -- an error that happens after the script starts running (it can't start running if it doesn't understand you -- a syntax error)


First: local must be lowercase.


:GetFullName() is not usually useful for scripts (i.e., it's only useful to humans). If you want a reference to an object, just use object itself, e.g.,

local player = game.Players.LocalPlayer

Now we want the player's Character. That will simply be

local character = player.Character

However, the Character won't load immediately. A simple way to do it is to wait() until you it's there:

repeat
    wait()
until player.Character
local character = player.Character

A more terse way to write it is

local character = player.Character or player.CharacterAdded:wait()

Now the character's Head is simply character.Head

Though it might be safer to wait for it to be there, hence, we could use

local head = character:WaitForChild("Head")
script.Parent.Adornee = head
Ad

Answer this question