I’ve messed around with it a lot and I still can’t find a solution. In this code sample, whenever the FixPos origin goes through, everything works fine but when I go through the Died origin, it doesn’t even reach the text.
I deleted the Died origin to check, and then the FixPos origin had the same problem as the Died origin. Just seems to happen whenever that remote goes through and the first if statement is true.
Is there any way to fix this? Thanks!
Can you screenshot or post the exact line were the error is coming from. Also could you send where your firing the remote from an any arguments you’re passing?
All of this just edits the way the camera is rotated depending on the mouse position on the screen, cameraPart is the point the camera stays stationary to.
At no point does cameraPart get set to nil, it’s either set to CharacterCustomization, characterPart, or Map Camera. Whenever it’s not being used, it just gets turned off, which is what the spectating if statement is used for.
It’s also of note that this error gets spammed into the console and doesn’t just repeat once.
The error only happens whenever the first if statement is connected, the FixPos still works. If the Died if statement is completely removed, however, the FixPos if statement will cause the same error I’m currently experiencing.
Under the “if playing” statement right before it errors, just print(cameraPart) and cameraPart.Parent. Double check to see if either of those end up returning nil
One is the cameraPart and PlayerCharacters is just a folder to store all of playerCharacters in.
After the remote goes through, the cameraPart becomes “Died” which has no parent. The name has nothing to do with the origin name from testing, and the word Died only shows up whenever the remote is sending or receiving the word.
I was trying to switch the camera to the main menu whenever the played was killed by the murderer (not the humanoid losing all its health, there is a state). However, when I set up the remote to receive the data that the player died, a part of the script that messes with the camera keeps getting set to something else for seemingly no reason or origin.
I tried restarting studio and other things to see if it was just a me-issue but the issue persisted. I tried bug fixing but even when the remotes receiving data are empty, the same issue happens. After that I have just been trying to track down specifically what the issue is. The cameraPart gets set to “Died” with seemingly no origin.
Thank you for the clarification, but there are some doubts in my mind regarding your issue.
Have you found the culprit? If so, can you show me which part of the script you suspect it is causing the issue? Can you also tell me what does the main script do and how it works?
The FixPos succesfully goes through every time but the Died if statement causes the issue, even when nothing is inside the Died statement. When the Died if statement is completely removed, then the FixPos statement will start the issue instead.
It just takes the part clicked that represents the player, sends the data that the player died and activates the remote.
This is the FixPos statement:
It just positions an object relative to each player so that it’s in the light. It takes the players in the game and sends the data to each of them.
cameraPart keeps getting set to something called “Died” whose parent is nil. No matter the condition of the remotes or order, it gets set to Died. The only time “Died” is referenced within all the scripts is whenever it’s mentioned in remotes.
Here’s a tip, are you sure you’ve inputted the arguments correctly?
The answer is no, because for the first argument, you input a non-player object. The first argument for the function is a player object for the remote to fire to. So to fix this, you must get the player object, and put it in the first argument of the function so it would look something like this:
FixPos is the data I send to let the client know to move a certain part in front of them, as the position of that part is client sided.
Died is the data I send to let the client know that the player has died, and to set everything back up to the main menu.
Whenever the remote connects, it messes up a different unrelated part of the script it’s in. The script it’s in handles all camera work, which is what Died is used for. Since the PlayerCharacter is set in that script also, I set FixPos into that script also to put the specific part in front of the PlayerCharacter.
Whenever I do this though, a completely unrelated part of the script sets a key part of itself to “Died” which is a string. At no point is the cameraPart set to a string, and no code within FixPos or Died affect this behavior whatsoever, it’ll just switch to “Died.”
The purpose of that part of the script is to edit the camera so that a slight angle is pointed wherever the mouse is pointed, and cameraPart is the set position for that.
I’m just really confused on how that even happens, there isn’t anywhere in any of the scripts this should happen. “Died” is just a string sent to let the client know the player needs to change the cameraPart to workspace.Map.Camera and to turn off “Playing” for the player.
I think it’s because you swapped the arguments in your FireClient() function.
When you called the same function for “FixPos”, you called it like this: sendDataRemote:FireClient(v, "FixPos", character)
The first argument is the player you want to fire the remote event to, second is the state and third is something else.
Always remember that the first argument of FireClient() is always the player object you want to fire the remote event to. So make it so that when you call FireClient() to give the “Died” data, the first argument is the player object, second is the state which is “Died” and third is something else which corresponds to the second parameter in the function connected to OnClientEvent.
I figured out the issue, and now I feel like a moron lol.
So when going through my screenshots you may see that the remote is called remoteTwo.
I was using the wrong remote for Died, which would explain all of my problems for all the strange behavior. I was using a remote that DIRECTLY changed cameraPart and because of my “player, origin, data” rule it would set the data to “Died.”
This would also explain why FixPos worked, as that uses the correct remote the entire time.
Thanks for helping me all through this problem, I should’ve just tried checking that since the beginning lol.
No problem, nothing else feels better other than after solving a painful problem. However, I would advise you to check every part of your script to ensure that it is not a silly mistake before you waste your precious time to finally find the tiny problem which could’ve been fixed a long time ago.