I have The Problem with the following. i get this error and i cant fix it "ReplicatedStorage.PlayerNameUIModule:4: attempt to index nil with 'Character' - Server - PlayerNameUIModule:4"
local PlayerNameUIModule = {}
function PlayerNameUIModule:init(player)
local Character = player.Character <----- **Error here**
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local BillboardGui = Instance.new("BillboardGui")
BillboardGui.Adornee = HumanoidRootPart
BillboardGui.Parent = Character
BillboardGui.Size = UDim2.new(0, 100, 0, 25)
BillboardGui.StudsOffset = Vector3.new(0, 3, 0)
BillboardGui.MaxDistance = 30
BillboardGui.AlwaysOnTop = true
BillboardGui.Name = "PlayerNameBillboard"
local TextLabel = Instance.new("TextLabel")
TextLabel.SizeConstraint = Enum.SizeConstraint.RelativeXY
TextLabel.Parent = BillboardGui
TextLabel.Size = UDim2.new(1, 0, 1, 0)
TextLabel.BackgroundTransparency = 1
TextLabel.TextColor3 = Color3.new(1, 1, 1)
TextLabel.TextScaled = true
TextLabel.Font = Enum.Font.SourceSansBold
TextLabel.Text = player.Name
end
return PlayerNameUIModule
and i got this LocalScript in StarterCharacterScript
-- LocalScript
local PlayerNameUIModule = require(game.ReplicatedStorage:WaitForChild("PlayerNameUIModule"))
local LocalPlayer = game.Players.LocalPlayer
local function onCharacterAdded(character)
PlayerNameUIModule:init(LocalPlayer)
end
LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
i can refrence the Character in the localscript but not in the module in ReplicatedStorage
** You are now Level 7! **