I was working on a game where it is mainly centered around the xbox controller. I thought it would be cool for the gamepad to rumble when you die, so I looked on the roblox wiki and made a localscript that looks like this:
local plr = game.Players.LocalPlayer
local haptics = game:GetService("HapticService")
plr.Character.Humanoid.Died:connect(function()
haptics:SetMotor(
Enum.UserInputType.Gamepad1,
Enum.VibrationMotor.Large,
0.8)
wait(0.4)
haptics:SetMotor(
Enum.UserInputType.Gamepad1,
Enum.VibrationMotor.Large,
0)
end)
It worked fine in the testing mode for studio, but when I tried it in my actual server, it did not work and it showed this error message:
Players.TroytheDestroyer.Backpack.Vibration:3: attempt to index field "Character" (a nil value)
I have worked with the property "Character" in a localscript before, but now all of a sudden it doesn't work.
Thank you!
