I’ve created a localscript that allows you to emote whenever you press the button “T”, but when you reset it does not work anymore. I’ve looked at other devforum posts about this but I could not get it to work in mine.
wait(1)
local Pose = script.Pose
local player = game:GetService("Players").LocalPlayer
local hum = player.Character:WaitForChild("Humanoid")
local PoseTrack = hum:LoadAnimation(Pose)
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.T then
PoseTrack:Play()
end
end)
UserInputService.InputBegan:Connect(function(input)
if input.UserInputType ~= Enum.UserInputType.MouseButton2 and input.UserInputType ~= Enum.UserInputType.MouseButton1 then
PoseTrack:Stop()
end
end)
I think the problem is the way you’re handling the variables. First of all, you should put that script into StarterCharacterScripts so is easier to locate the character. After doing that, change your script to something like this:
local Character = script.Parent or game.Players.LocalPlayer.CharacterAdded:Wait()
local Hum = Character:WaitForChild("Humanoid", 10)
local Pose = script:WaitForChild("Pose", 10)
local PoseTrack = Hum:LoadAnimation(Pose)
local ContentProvider = game:GetService("ContentProvider")
local UserInputService = game:GetService("UserInputService")
ContentProvider:PreloadAsync({PoseTrack})
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.T then
PoseTrack:Play()
end
end)
UserInputService.InputBegan:Connect(function(input)
if input.UserInputType ~= Enum.UserInputType.MouseButton2 and input.UserInputType ~= Enum.UserInputType.MouseButton1 then
PoseTrack:Stop()
end
end)