So the context is, that I was trying to get Mouse.Hit and put it in a CFrameValue every time that a player’s mouse is moved. But every time I ran the script it would give this error.
I’m still trying to understand why it won’t work. Here are the scripts:
LocalScript:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Mouse = player:GetMouse()
Mouse.Move:Connect(function()
task.wait()
print("Yeepie it works!")
local MousePos = Mouse.Hit
script.MousePosition:FireServer(Mouse, MousePos)
end)
ServerScript:
script.Parent.OnServerEvent:Connect(function(Mouse, MousePos)
local CFrameVal = script.Parent.CurrentMousePosition
CFrameVal.Value = MousePos
print(CFrameVal) --checking if it works
end)
When you’re firing the remote you sent the mouse and the mouse position as a parameter.
Fix:
Replace in Local Script, where you’re firing the remote:
script.MousePosition:FireServer(MousePos)
Replace in ServerScript
script.Parent.OnServerEvent:Connect(function(Player, MousePos)
local CFrameVal = script.Parent.CurrentMousePosition
CFrameVal.Value = MousePos
print(CFrameVal) --checking if it works
end)
Do what @killermurderator said, I didn’t notice you had the parameters wrong on the remote event, remember that the first parameter to the function when responding in a server script will always be the player.