local replicatedStorage = game:GetService("ReplicatedStorage") local players = game:GetService("Players") local tweenService = game:GetService("TweenService") local userInputService = game:GetService("UserInputService") local activeTweens = {} local activeAnimationTrack = nil local activeModel = nil local emoteActive = false local function spinParts(model) for _, part in ipairs(model:GetDescendants()) do if part:IsA("BasePart") and (part.Name == "Middle" or part.Name == "Outer") then local tweenInfo, goal if part.Name == "Middle" then tweenInfo = TweenInfo.new(12.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, false, 0) goal = { Orientation = part.Orientation + Vector3.new(0, -360, 0) } elseif part.Name == "Outer" then tweenInfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, false, 0) goal = { Orientation = part.Orientation + Vector3.new(0, 360, 0) } end local tween = tweenService:Create(part, tweenInfo, goal) tween:Play() table.insert(activeTweens, tween) end end end local function placeModelUnderLeg() local player = players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") if humanoidRootPart then local assetsFolder = replicatedStorage:FindFirstChild("Assets") if assetsFolder then local effectsFolder = assetsFolder:FindFirstChild("Effects") if effectsFolder then local modelTemplate = effectsFolder:FindFirstChild("NightmareEmote") if modelTemplate and modelTemplate:IsA("Model") then local clonedModel = modelTemplate:Clone() clonedModel.Parent = workspace if clonedModel.PrimaryPart then clonedModel:SetPrimaryPartCFrame(humanoidRootPart.CFrame - Vector3.new(0, 3, 0)) else warn("PrimaryPart not set for NightmareEmote model!") return end spinParts(clonedModel) activeModel = clonedModel else warn("NightmareEmote model not found or is not a valid model!") end else warn("Effects folder not found in Assets!") end else warn("Assets folder not found in ReplicatedStorage!") end else warn("HumanoidRootPart not found in character!") end end local function playAnimation(animationId) local player = players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:FindFirstChild("Humanoid") if humanoid then local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid) local animation = Instance.new("Animation") animation.AnimationId = animationId activeAnimationTrack = animator:LoadAnimation(animation) activeAnimationTrack:Play() else warn("Humanoid not found in character!") end end local function stopEffects() for _, tween in ipairs(activeTweens) do tween:Cancel() end activeTweens = {} if activeAnimationTrack then activeAnimationTrack:Stop() activeAnimationTrack = nil end if activeModel then activeModel:Destroy() activeModel = nil end emoteActive = false end local function monitorWalking() local player = players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:FindFirstChild("Humanoid") if humanoid then humanoid.Running:Connect(function(speed) if speed > 0 and emoteActive then stopEffects() end end) else warn("Humanoid not found in character!") end end local function activateEmote() if emoteActive then return end emoteActive = true local success, err = pcall(function() monitorWalking() placeModelUnderLeg() playAnimation("rbxassetid://9191822700") end) if not success then warn("Error occurred: " .. tostring(err)) emoteActive = false end end userInputService.InputBegan:Connect(function(input, gameProcessedEvent) if gameProcessedEvent then return end if input.KeyCode == Enum.KeyCode.M then activateEmote() end end)