Input Position not working(believe)

Hello, I am using InputObject.Position, but I need that value in real time, can someone tell me what is happening?

My Code:

function RotateModelInput(val)
	print(val)
	local model = workspace.PartsToFunSpawn:FindFirstChildWhichIsA("Model")
	if model and model.PrimaryPart then
		model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(val), 0))
	end
end
local id = nil
local e 
function OnInputBegan(input:InputObject)
	if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
		print("Hola")
		id = input
		local pos = input.Position.X
		e = input:GetPropertyChangedSignal("Position"):Connect(function()
			if id == input then
				print(pos)
				local val = (pos - input.Position.X)/10
				RotateModelInput(val)
				pos = input.Position.X
			end
		end)
	end
end

function OnInputEnded(input)
	if input == id then
		id = nil
		e:Disconnect()
		print("Fin")
	end
end
1 Like

Store the position into a variable you an acess outside of the function
then make a loop/RunService connection to update whatever you need with it

1 Like

It still doesn’t work, in fact, that was the one I used at first. same result

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.