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

What does W001:Unknown global 'character' and W001:Unknown global 'player' mean?

Asked by 4 years ago
Edited 4 years ago

So I'm seeing this blue underline appear under character and player in this code:

        if **character**.Head:FindFirstChild("BillboardGui") then
            local clonedgui = billboardgui:Clone()
            clonedgui.TextLabel.Text = "Guest"
            clonedgui.TextLabel.TextColor3 = Color3.fromRGB(75,171,144)
            clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
        end

        if **player**:IsInGroup(5330388) then
            local clonedgui = billboardgui:Clone()
            clonedgui.TextLabel.Text = "Trainee"
            clonedgui.TextLabel.TextColor3 = Color3.fromRGB(0,230,255)
            clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
        end

I've put asterisks around the character and player where the blue underline appears. If anyone knows how to solve this, please answer! It'd mean a lot for myself and the game I'm working on!

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

lets do some steps: 1-- have you checked if you are putting this code in a function?

2-- did you put "local" infront when you were creating the "character" and "player" variables? (will not let functions that do not have "character"/"player" identified)

3-- did you create/identify the variables "character" and "player"?

Ad
Log in to vote
1
Answered by
megukoo 877 Moderation Voter
4 years ago

W001:Unknown global means that you are trying to use a variable a reference has not been created for.

An example that would produce W001: Unknown global would be:

local a = 10

function sum()
    return a + b -- we have not declared a value for b, yet try to use it
end

To fix this, you need to make define player and character somewhere in your script.

0
Thanks so much! Now I know for future reference. :) jaxtronomical 7 — 4y

Answer this question