Points dont add up to other points/another type of points add up to other points but revert when player collects something that has another type of points

i moved it to ui but i cant assign ui to the ghosts

Seems like UI is in a similar place to the points manager, why can it not be assigned? Does your ghost script use an @export with PointsManager as itā€™s type? If so change the @exports type to ā€œUIā€

i looked through the ghost script and found this:
@export var points_manager: PointsManager

pointsmanager has a class name btw

i changed @export var points_manager: PointsManager to @export var points_manager: UI

1 Like

and i assigned ā€œUIā€ to the ghosts since it has a box to assign it to
does that mean i have to put @export var points_manager: UI in scripts assigned to nodes that have points?

as usual, waiting for a reply

Probably? Iā€™m sure you can try and find out if it gives a similar error. You havenā€™t shown me any other ā€œscripts assigned to nodes that have pointsā€ so I do not know how they differ from our conversation thus far.

I would say most of your points management code should be part of the UI node, since the two are so interconnected, when you want to add points you also want to display points. If you can merge all of the points manager code into UI I think that would help you out with your assignment confusion.

i see
btw here is another script:

extends Area2D

class_name Fruit

@onready var fruiteaten_player = $"../soundPlayers/fruiteaten_player"
@onready var label = $Label
@onready var cherries = $Cherries
@onready var ui = $"../UI" as UI

const BASE_POINTS_FOR_CHERRIES_VALUE = 100
var cherries_points = BASE_POINTS_FOR_CHERRIES_VALUE
var points = 0






func _ready():
	label.hide()
	set_collision_mask_value(1, false)
	hide()
	await get_tree().create_timer(45).timeout
	set_collision_mask_value(1, true)
	show()
	await get_tree().create_timer(30).timeout
	set_collision_mask_value(1, false)
	hide()

btw i also tried to merge the points manager code into UI, here is it:

extends Node

class_name UI

@onready var center_container = $MarginContainer/CenterContainer
@onready var life_count_label = %LifeCountLabel
@onready var game_score_label = %GameScoreLabel
@onready var points_manager = $"../pointsManager" as PointsManager




@onready var ui = $"../UI" as UI


const BASE_POINTS_FOR_GHOST_VALUE = 200
const BASE_POINTS_FOR_PELLET_VALUE = 10
const BASE_POINTS_FOR_POWERPELLET_VALUE = 50

var ghost_points = BASE_POINTS_FOR_GHOST_VALUE
var pellet_points = BASE_POINTS_FOR_PELLET_VALUE
var powerpellet_points = BASE_POINTS_FOR_POWERPELLET_VALUE
var points = 0


func pause_ghost():
	points += ghost_points
	get_tree().paused = true
	await get_tree().create_timer(1.13).timeout
	get_tree().paused = false
	ghost_points += BASE_POINTS_FOR_GHOST_VALUE
	ui.set_score(points)



func reset_points_for_ghosts():
	ghost_points = BASE_POINTS_FOR_GHOST_VALUE





func set_lifes(life):
	life_count_label.text = "%dup" % life
	if life == 0:
		game_lost()

func set_score(score):
	game_score_label.text = "HIGH SCORE 
	%d" % score

func pellet_points_eaten():
	points += pellet_points
	ui.set_score(points)



func game_lost():
	get_tree().change_scene_to_file("res://SCENES/gameover.tscn")

i have also added @export var pointsmanager: UI on the pellet_manager script (theres no underscore in pointsmanager because its to differnate from the real points_manager"

@gertkeno