Mouse.Hit.P breaks with FireAllClients

Same ability as the last post but I noticed when testing with multiple people the ability fires towards the casters mouse for the caster but on other people screens it fires towards their mouse instead of the casters. I assume its because of the FireAllClients but I can’t find a way around it, using the mouse hit as a parameter in the event wont work unless I want the ability to be unreliable as it is a barrage ability so you wouldn’t be able to aim it

local Plr = game.Players.LocalPlayer
local mouse = Plr:GetMouse()

   local Pos = mouse.Hit.p

   local TI =
	    (Star.Position - Pos).Magnitude * 0.3 / 50,
   TS:Create(Star,TI,{CFrame =}):Play()

This isn’t the full script but I doubt the rest of it is important. Getting the mouse from the P parameter in the event still works on the casters screen but on other peoples screen the projectiles don’t move at all.

Example of what’s happening

In FireAllClients() you’re supposed to send the caster’s mouse position, not use theirs OnClientEvent()

I explained why that’s a bad idea

There’s no other way using mouse, try raycasting instead.

I think I figured something out hold on

Kind of upset that I didn’t think of this sooner but I could have just made the fireserver event under a loop instead with the mouse parameter in the event

That’s what you’re supposed to do because the mouse you sent won’t update on the server, because only the player can access it. So everytime you want to update it you gotta FireServer() again.

1 Like

What you needed to do is pass the fired client as an additional argument to the RemoteEvent:FireAllClients() call, then in the callback function connected to the same RemoteEvent’s ‘OnClientEvent’ event/signal you needed to perform the following check.

local LocalPlayer --This would need to be defined.

local function OnRemoteFired(Player)
	if Player ~= LocalPlayer then return end --Immediately return out of the function if the remote's player and the local player do not match.