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

Why mouse of player is a nil value?

Asked by 4 years ago
local event = script.Parent.Parent.Event
local cursor = script.Parent.Cursor

local function OnEvent(player)
    print(player)
    local mouse = player:GetMouse()
    print(mouse)
    while true do
        cursor.Position = UDim2.new(0,mouse.X,0,mouse.Y)
    end
end

event.OnServerEvent:Connect(OnEvent)

I did everything right, ClassName is "script", but :GetMouse doesn't works, it just gives nil value, I want to make a cursor on SurfaceGui

1 answer

Log in to vote
0
Answered by 4 years ago

You cannot pass the GetMouse instance to the server, it can only be done on a LocalScript.

For further information please see: https://scriptinghelpers.org/questions/54579/anyways-to-grab-getmouse-from-local-script-to-server-script

You can, however, pass the Mouse.Hit and Mouse.Target and other properties.

If you see this as a direct answer to your question, consider making this an 'accepted answer'

Ad

Answer this question