EekPlayz09
(PVP_ImUnclePeteInBed)
July 1, 2023, 3:57pm
#1
My script needs to be ran on the server so i send a remote event to the client
–Server
local MouseP = game.ReplicatedStorage.MousePos:FireAllClients(MouseP)
print(MouseP)
–Client
game.ReplicatedStorage.MousePos.OnClientEvent:Connect(function()
print(Mouse.Hit.Position)
return(Mouse.Hit.Position)
end)
on the client it prints the position but on the server it prints nil
This is because the server has no mouse. Just send a client event using the same Remote Event with the mouses position.
1 Like
EekPlayz09
(PVP_ImUnclePeteInBed)
July 1, 2023, 4:01pm
#3
yea it sends request to the client to get the mouse then return it to the server
But you didn’t show the script that returns it to the server.
EekPlayz09
(PVP_ImUnclePeteInBed)
July 1, 2023, 4:04pm
#5
right there (filling space innnnn)
That only shows the client event. You cannot return a value from 2 separate scripts.
Quwanterz
(Quwanterz)
July 1, 2023, 4:11pm
#7
You cannot return a value with a RemoteEvent as they are a one-way communication. RemoteFunctions is what you need as it allows two-way communication.
But why are you trying to return the Mouse object from the client to the server? Why not return the Hit.Position instead? If you think this will protect it from exploiters, then I can assure you it won’t.
EekPlayz09
(PVP_ImUnclePeteInBed)
July 1, 2023, 4:15pm
#8
no its bc an npc needs to move from a players mouse pos and npc moves on server so it needs to send request from server to client to server
Quwanterz
(Quwanterz)
July 1, 2023, 4:17pm
#9
My bad. It seems I have misread your script. Then as I have mentioned, you need to use a RemoteFunction for this.
system
(system)
Closed
July 15, 2023, 4:18pm
#11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.