Serverscript confuses a part variable and the player

Hello. On a localscript im passing on a .target variable which is defined like

local target = players.Localplayer:GetMouse().Target

I pass it onto another localscript by

game.StarterPlayer.StarterPlayerScripts.Bindableevent:Fire(player, target)

I transfer player too because im firing the bindableevent whenever i press F
I pass it into a bindablevent. Then another localscript gets target and player by

game.StarterPlayer.StarterPlayerScripts.Bindableevent.Event:Connect(function(player, target)

Then i pass it further on when i press C. I pass it on by a remoteevent to a script and i pass on player, target. The script gets both player, target. On the script the target block will accelerate forward by

	target.LinearVelocity.VectorVelocity = dir * 10

Dir is


But heres the problem. The game seems to think that target is the player for some reason. Sorry if its to understand my description of this entire post. Thank you.

You don’t need to specify the player when firing a bindable event. Since bindable events on the client will only be recieved on the client, there is no need to pass the player.

1 Like

Also. I just realized that i have a variable called player





Great. But how do i pass the player from the 2nd localscript to the script? Im using remoteevents.

target is defined as nil in the script

just do RemoteEvent:FireServer(target)

But I dont know why youre passing the value around so much. It would be way easier just calling Fireserver right away.

The reason for me passing it so much is because the first localscript is responsible for selecting an object and passing it to the second localscript. The second localscript i will store all the different keys you can press and they will send it to different serverscripts depending on which one you press. The serverscript needs to know the target so that it does the right thing to the right object. The player is just to get the lookvector.

I experimented a bit with this and it worked perfectly. Thank you!

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