GetMoveVector() always returns (0, 0, 0)

I’m trying to get the player’s move vector using the GetMoveVector() function from the ControlModule, but it always returns (0, 0, 0) even if the character is moving. What am I doing wrong?

Script:

local GetMoveVector = require(game:GetService("Players").LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("ControlModule")):GetMoveVector()
game:GetService("RunService").Heartbeat:Connect(function()
	print(GetMoveVector)
end)
1 Like

You are storing the value from calling the function outside the event, not the function reference. Here is a cleaned and working version of your code:

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Scripts = Player:WaitForChild("PlayerScripts")

local ControlModule = require(Scripts:WaitForChild("PlayerModule"):WaitForChild("ControlModule"))
RunService.Heartbeat:Connect(function()
	print(ControlModule:GetMoveVector())
end)

P.S: I didn’t knew that function was a thing.

2 Likes