Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
6 years ago

There's a way to get the mouse's CFrame in the game, using mouse.Origin. Wiki link: https://wiki.roblox.com/index.php?title=API:Class/Mouse/Origin

0
I don't get how this will make so the server will constantly have the renewed mouse Position LuaPrescott 2 — 6y
Ad
Log in to vote
0
Answered by
F_F 53
6 years ago

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)

Answer this question