Attempt to Call a Vector3 Value?

I’m trying to create a flying effect on the player, and I’m using a module script to do everything. I’ve created a remotefunction to get the player’s mouse so that it would be able to fly towards the mouse’s position.

	while self.flying do
		rs.Heartbeat:wait()
		first, second = self.mouseHit:InvokeClient(Playerr)
		print(first,second)
		self.bodyPosition.Position = self.humanoidCharacter.HumanoidRootPart.Position -((self.humanoidCharacter.HumanoidRootPart.Position - first).unit * self.speed)
		self.bodyGyro.CFrame = CFrame.new(self.humanoidCharacter.HumanoidRootPart.Position, self.humanoidCharacter.HumanoidRootPart.Position + second)
	end

^^ this is inside the module script

function MouseThing()
	local mouse = Player:GetMouse()
	local hitp = mouse.Hit.p
	local hitl = mouse.Hit.LookVector
	return hitp, hitl
end

remoteFunctions.trackMouse.OnClientInvoke = MouseThing()

^^ This is inside the local script

It errors and tells me “Attempt to call a vector3 value”.

1 Like

What? mouse.Hit is a CFrame. Why is it one? Beyond me. The issue is here:

MouseThing returns 2 Vector3s, but since you’re using the result and giving OnClientInvoke that result, it gets the first vector, and tries calling the vector. Remove the parentheses, and problem solved. It is also bad practice to use OnClientInvoke, so I recommend you make this a RemoteEvent instead, listening for OnServerEvent. You would then just pass the mouse values you need to pass.

2 Likes

Thanks for that, I seem like such an idiot.

1 Like