hello, ive been making my game and wanted to add player’s portrait to healthbar background, created a modulescript which will get players character and then insert it into frame where player’s portrait should be
but, player’s character dont appear and i dont know why
module:
local module = {
configuration = {
Position = Vector3.new(0, -1, 0);
Orientation = Vector3.new(0, -180, 0);
PrimaryPart = "HumanoidRootPart"
}
}
local hud = script.Parent.Parent
local mainframe = hud:WaitForChild("mainframe")
local portraitframe = mainframe:WaitForChild("stats_hp"):WaitForChild("health_holder"):WaitForChild("portrait")
local lp = game.Players.LocalPlayer
function module:_get_player_portrait()
local character_portrait = game.Players:CreateHumanoidModelFromUserId(lp.UserId)
return character_portrait
end
function module:BuildPortrait()
local character = module:_get_player_portrait()
character.PrimaryPart = character:WaitForChild(module.configuration.PrimaryPart)
character.PrimaryPart.Position = module.configuration.Position
character.PrimaryPart.Orientation = module.configuration.Orientation
character:PivotTo(portraitframe:WaitForChild("portrait_example").HumanoidRootPart.CFrame)
character.Parent = portraitframe
end
return module
localscript:
local p = require(libs:WaitForChild("HUD_Portrait"))
p:BuildPortrait()
how it should be:
how it appears:
no errors in console
player’s character actually appears in frame, but i dont see it