UI is not persistent. Jumping from player to player???

 RemCoreHealth_UI(Player:player):void=
        if(PlayerUI := GetPlayerUI[Player],  temp:=CanvasMap[Player]?):
            PlayerUI.RemoveWidget(temp)

    Initialize(Player:player):void=
        if(PlayerUI := GetPlayerUI[Player]):
            tempCanv:=CreateUIForPlayer(StackBox_X,StackBox_Y)
            if(set CanvasMap[Player] = option{tempCanv}):
                PlayerUI.AddWidget(tempCanv)
CreateUIForPlayer(UIX: float, UIY: float):canvas=

        #GUIWidget.SetText(GUIText1())
        Blue_TextWidg.SetText(TextToMsg("{CoreHealth}"))
        Red_TextWidg.SetText(TextToMsg("{CoreHealth}"))

        MyCanvas : canvas = canvas:
            Slots := array:
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 0.00, Y := 0.0}, Maximum := vector2{X := 0.0, Y := 0.0}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := UIX, Y := UIY}
                    SizeToContent := true
                    Widget := stack_box:
                        Orientation := orientation.Horizontal
                        Slots := array:
                            stack_box_slot:
                                Padding:=margin{Top := 0.0, Left := Blue_UI_PaddingLeft, Right := Blue_UI_PaddingRight, Bottom := 0.0}
                                Widget := Blue_TextWidg
                            stack_box_slot:
                                Padding:=margin{Top := 0.0, Left := Red_UI_PaddingLeft, Right := Red_UI_PaddingRight, Bottom := 0.0}
                                Widget := Red_TextWidg

For some reason the result of this code is the UI jumping from player to player depending on who calls “Initialize” or “RemCoreHealth”. Like it is not persistent, or its not actually creating a new canvas for the player at “tempCanv”.
What am I doing wrong here?

This thread may have some answers for you :

Well conceptually it makes no sense. But I have seen that method before. I was trying to avoid making an entire class for such a simple UI, but I guess I dont have a choice. Thank you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.