Mouse.Hit.Position

Why wont Mouse.Hit.Position work?

assets.Remotes.HookReplicate.OnServerEvent:Connect(function(player)
	print("ODMGEARRRR")
	local part = assets.Hook:Clone()
	print("GOTHOOK")
	local mouse = player:GetMouse()
	print("GOTMOUSE")
	local odmg = player.Character:FindFirstChild("Odmg")
	print("GOTODMG")
	part.Position = mouse.Hit.Position
	print("PARTPOSITION")
	part.Parent = game.Workspace
	odmg.LeftGrapple2.Beam.Attachment1 = part:FindFirstChild("A1")
	print("SUCCESS")
end)

Everything works until Mouse.Hit.Position

1 Like

Hi. Do you receive an error message in the output? Does everything below mouse.hit.position work?

1 Like

Hey. No there are no errors, and no nothing below mouse.hit.position works

1 Like

I don’t use mouse.Hit or the mouse object at all so I’m not sure but. I don’t think the mouse can be captured from the server. You’d be better off getting the mouse object or mouse.Hit from the local script then send it to the server script that you’re trying to use it in.
i.e., assets.Remotes.HookReplicate.OnServerEvent:Connect(function(player, mouse)

2 Likes

Hmm but then what would i do to clone the part to the mouse position?

You are correct that the mouse can only be accessed by client scripts. If you ever want the server to have mouse.Hit.Position, then it must be sent with the RemoteEvent. I don’t believe sending the mouse class will work either.

1 Like

As @ZoomSummit said, you will have to pass the mouse.Hit to the server script via the remote event you already are firing.

It’s gonna look something like:

assets.Remotes.HookReplicate.OnServerEvent:Connect(function(player, mouseHitPosition)
-- Hiding the rest of the function to save space
-- Local script
remoteEvent:FireServer(mouse.Hit.Position)
2 Likes

so something like this?
Assets.Remotes.HookReplicate:FireServer(mouse.Hit.Position)

2 Likes

Yes! Exactly like that!

[char limit]

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