Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make so the server constantly has access to the mouse position?

So basically I am making a script where, if you press C, you fly and your character flies to where your mouse is aiming for 3 seconds. But I don't know how to make so the server has constantly access to the mouse Position. Here's my local script

if input.KeyCode == Enum.KeyCode.C then
			if not flightEnabled then return end
			
			handler:FireServer({"Fire", "Flight"})
			
			local cd = Instance.new("IntValue", player.Character)
			cd.Name = "FlightCooldown"
			cd.Value = 14
			cooldownGui.Flight.FlightFrame.BackgroundTransparency = 0.3
			
			for i=1, 13 do
				cd.Value = cd.Value - 1
				cooldownGui.Flight.FlightText.Text = cd.Value
				wait(1)
			end
			
			cooldownGui.Flight.FlightText.Text = "C"
			cooldownGui.Flight.FlightFrame.BackgroundTransparency = 1
			cd:Remove()
			flightEnabled = true
		end
end)

2 answers

You will get the player's mouse position by doing this:

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()


then you will want to update the mouse whenever it's moved


Mouse.Move:Connect(function()
	local mousePosition = Mouse.Hit.p

	 --- send the mousePosition to the server using remote events
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.