Is there something that I am not noticing with this error?

Hello.

Yesterday, I created a post talking about this annoying error that I would get everytime a player would grab this boomerang item, and I found a solution to it, and the solution works only one time.

So when a player throws the boomerang on their first attempt, then grabs it back, there is no " attempt to index nil with ‘D’ ". Now, when a player attempts to throw the boomerang a second time, I get the same error that I got from yesterday.

Is there even a fix to this? How would I fix it?


Here is the code, and I fixed a bit of things up:

I don’t know what to really do now.
Any help is appreciated.

Could you highlight / show which line is erroring?

Maybe try printing the BodyPos’s name and see if it gives an error or is nil.

I know you did a check with that if statement but let’s find out if it even exists the second time

The body position might have been removed when it comes back after the initial throw

Just made a print system type of thing that will print out if it is nil or not, and it does print out when the bodypos is nil or not.

I have tried using a for loop to get rid of all of the BodyPositions inside of the boomerang, and it works, but it doesn’t solve the problem.

Would you like the place file for the game?

Yeah, that’s what is supposed to happen, like when you catch a boomerang irl, the movement of the boomerang stops.

1 Like

Cant rn cuz I’m at school so all I can really do it type in my phone

Ah okay, I thought you just set the MaxForce of it to 0 or anchored it (dunno much about Roblox’s physics and constraints).

So the second time when you throw the boomerang; is there a BodyPosition in it or not?

1 Like

I’m not sure that can be called in a modular script. You would have to call it with the player in a local script.

local player = game.Players.LocalPlayer
local MyModule = require(game.ReplicatedStorage.MyModuleScript)

MyModule.GreetPlayer(player)

Sometimes you just have to try printing things to see if they are indeed working.
Try: print(plr) to see if it’s even getting the player …

Now that you mention that, I have noticed that it literally duplicated the BodyPosition and BodyAngularVelocity after the second throw. … Oh no.

Here is a video of it:

1 Like

Yes, it can be called in a ModuleScript. It seems like it is an issue with the BodyVelocity, BodyAngularVelocity and BodyPosition duplicating after the 2nd throw.

Its like it duplicates as much times as you throw, for example. If you thrown the boomerang a 2nd time, it duplicates 2 times since you’ve thrown it two times. If you throw the boomerang a 3rd time, it triples since you threw the boomerang three times.

That is pretty much the problem, and I can’t seem to figure it out.

1 Like

Hm that’s weird, yeah it’s def duplicating more than it should be.

What if I just add a BodyPosition and an AngularVelocity to the Boomerang when the player equips it? So we don’t have to always make a new instance once a player throws the boomerang.

Then once the player unequips the boomerang, I can just delete the boomerang and then everything is under control.

Your mention about there being a BodyPosition, helped me at least get kind of a solution, thank you man.

bump, it’s still not working man : - /

1 Like

Btw, I have made a boomerang in the past, and it is working beautifully, than this. I wanted to code it where you press a key to throw the boomerang and it is just a mess, so ima just take notes from the old boomerang I constructed, I guess.

1 Like

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