What Am I doing wrong?

I’m trying to make a scoring system for my first game. What am I doing wrong? It’s giving me this notice and the my script doesn’t work at all. :confused:

Each possible execution path should have a return node, here Cast Failed doesn’t.
The cast is probably failing if you are getting no result, is PhysicsBallBP actually the owning pawn of the widget?

Thank you for the respond man :slight_smile: I managed to get rid of the note by putting another return node on the cast fail. But I think for some reason, it’s always failing.
Would you mind telling me what’s my mistake here? Sorry I’m new :cry:



Right click and put a breakpoint on your code and see what happens. Print string is also very handy too for debugging what values you are actually getting while you play

There’s a few things that could be wrong here.

Firstly, you haven’t actually fixed the original problem, your return node for Cast Failed, is still getting a variable from PhysicsBallBP, but if the casts has failed, it won’t be able to do that, giving you an error. Ideally your cast would never fail if you’re doing things right but still it shouldn’t be set up like that. If the cast fails, return no text.

Your OnOverlap event looks ok, but is it possible for something that isn’t PhysicallBallBP to overlap the mesh? Because if it does, the cast will fail. Like ZoltanJr said, you should put in some print strings to see what’s working. You can compare the class of the overlapped actor using the == node, to see is it equal to PhysicsBallBP, and only cast if it is. Definitelt make sure that overlap event is actually working though with some print strings.

Also, is PhysicsBallBP actually a pawn? Is it the pawn your user possess when playing, or is it just an actor?

Can I ask why you have a separate blueprint to add your UMG Widget? I’m not sure why it is needed.
If I were doing this and it was a single player game, I’d put everything on the player controller or character.
When your pawn overlaps the score BP, you can update the UMG from the controller or character…don’t need the function on the UMG at all.