Unable to cast token to token

hi, i was working at a VR project and i use HapticService to make Controlers Vibrate when they die, the problem is i always get this error:
23:42:48.842 - Unable to cast token to token

the script:


game.ReplicatedStorage.VRRemotes.VibrateMotors.OnClientEvent:Connect(function()
	for _,Item in next,AllMotors do
	   if HapticService:IsVibrationSupported(Item) == true then
		    HapticService:SetMotor(Item,Item,0.8)
			delay(0.8,function()
			    HapticService:SetMotor(Item,Item,0.8)
			end)
		end
	end
end)

the rror line: 8, if HapticService:IsVibrationSupported(Item) == true then

IsVibrationSupported takes a UserInputType, not a Motor.
Also, SetMotor takes the UserInputType and then the Motor.

2 Likes

oh, but what type of UserInputType i need to use?

You would use whichever gamepad is currently being used, such as Gamepad1. I’m not sure how VR remotes are mapped as gamepads though.

If you want to test an individual motor, use IsMotorSupported.

1 Like

hi, that works but what Enum is Gamepads?

They’re also UserInputTypes. E.g. Enum.UserInputType.Gamepad1