I want to send an object from a serverscript to a localscript using a remote event, simple enough however the object is a cloned part so if i try to put in the reference into the remote event box it returns as nil on the local script, how do i get around this?
Make sure that what you are firing as a parameter for the remote event exists. Check if “game.Players:GetPlayerFromCharacter(script.Parent.Parent).proj)” exists using a if statement and print the result.
I figured out why it wasnt working - the server script fired the remote event before proj was created, however now how do i make sure that proj exists in the server before firing the remote event?
First, create a variable that equals "game.Players:GetPlayerFromCharacter(script.Parent.Parent).proj). Then, use an if statement to see if the variable is not equal to nil. Inside of that if statement, you can fire the remote event. The parameter of the FireClient function should be the variable that you created. If you specifically want to wait until the proj is created, you can add a :WaitForChild, and the variable would be “game.Players:GetPlayerFromCharacter(script.Parent.Parent):WaitForChild(“proj”)”
The projectile is a parent of workspace, not the player and secondly i cant do the if statement inside of the server script since it will always say that it exists even if i check right after the projectile is created even though the localscript doesnt recognize it.
Inside of the FireClient, you fired “game.Players:GetPlayerFromCharacter(script.Parent.Parent).proj” as a parameter. If the projectile is a parent of Workspace, then this parameter should also be rewritten
Theres a comma there, not a dot. Im firing the player as a parameter first because the remote event is fired from a server script so that the local script can pick it up
First of all, why do you need to run the .Touched event on the client if nothing is being done but fire the server again? Couldn’t the .Touched event run on the server and access obj.Damage.Parent?
The whole point of doing collision checks on the client is to eliminate lag from server to client. After setting network ownership this is what projectiles look like when i check for touched events on the server, they clip through parts before registering.
discussed privately with doc about the problem
the issue was the object not loading upon event being fired so I told him to simply put “game:GetService(“Runservice”).Heartbeat:Wait()” before firing the remote event. I hope this is useful for people who has had the same problem.