I have searched the internet for over an hour now and, sadly, I still cant find a solution.
I am working on a game and I have to create a stand, this stand is a machine. That is why I need it to run with the player!
I have attempted to use MoveDirection (if humanoid.MoveDirection ~= Vector3.new(0,0,0) then) but if the player switches directions the animation plays again. I have tried humanoid.Running but this fires it multiple times, and, of course, also plays again.
What do I mean by play again? Well, while its playing the run animation, it immediately skips to the beginning.
I have a Server Script and Local Script.
Local Script:
local Player = game.Players.LocalPlayer local rp = game:GetService("ReplicatedStorage") local Stand = rp:WaitForChild("Stand5Remotes"):WaitForChild("Stand") local UIS = game:GetService("UserInputService") local debounce = false local active = false UIS.InputBegan:Connect(function(input,isTyping) if isTyping then return elseif input.KeyCode == Enum.KeyCode.Q then if debounce == false and active == false then debounce = true Stand:FireServer(active) end end end) UIS.InputBegan:Connect(function(input,isTyping) if isTyping then return elseif input.KeyCode == Enum.KeyCode.Q then if debounce == true and active == false then active = true Stand:FireServer(active) end end end) Stand.OnClientEvent:Connect(function() wait(1) debounce = false active = false end)
Server Script:
local rp = game:GetService("ReplicatedStorage") local Stand = rp:WaitForChild("Stand5Remotes"):WaitForChild("Stand") local TweenService = game:GetService("TweenService") Stand.OnServerEvent:Connect(function(player,active) if active == false then local Character = player.Character local Humanoid = Character:WaitForChild("Humanoid") local HumanoidRP = Character:WaitForChild("HumanoidRootPart") local Folder = Instance.new("Folder",workspace) Folder.Name = player.Name.." Stand" local Mystand = script:WaitForChild("Dummy"):Clone() Mystand.Parent = Folder for _, i in pairs(Mystand:GetDescendants()) do if i.Name == "Window" and i:IsA("BasePart") then i.Transparency = 0.85 else if i:IsA("BasePart") then i.Transparency = 1 TweenService:Create(i,TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0),{Transparency = 0}):Play() end end end Mystand:WaitForChild("Root").CFrame = HumanoidRP.CFrame * CFrame.new(0,7,0) local animControl = Mystand:WaitForChild("AnimControl") local idle = animControl.Animator:LoadAnimation(script:WaitForChild("Idle")) idle:Play() local plridle = Humanoid.Animator:LoadAnimation(script:WaitForChild("PlrIdle")) plridle:Play(.4) local run = animControl:LoadAnimation(script:WaitForChild("Run")) local weld = Instance.new("ManualWeld") weld.Name = "Stand Weld" weld.Part0 = Mystand:WaitForChild("Root") weld.Part1 = HumanoidRP weld.C0 = Mystand:WaitForChild("Root").CFrame:inverse() * HumanoidRP.CFrame weld.Parent = weld.Part0 Humanoid.Died:Connect(function() Folder:Destroy() end) Humanoid.Changed:Connect(function() if Humanoid.MoveDirection ~= Vector3.new(0,0,0) then run:Play() else run:Stop() end end) end end) Stand.OnServerEvent:Connect(function(player,active) if active == true then local Character = player.Character local HumanoidRP = Character:WaitForChild("HumanoidRootPart") local Humanoid = Character:WaitForChild("Humanoid") local myStand = workspace:WaitForChild(player.Name.." Stand") for _, i in pairs(myStand:GetDescendants()) do if i:IsA("BasePart") then local Tween = TweenService:Create(i,TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0),{Transparency = 1}) Tween:Play() Tween.Completed:Connect(function() myStand:Destroy() end) end end for _, i in pairs(Humanoid:GetPlayingAnimationTracks()) do i:Stop(.4) end Stand:FireClient(player) end end)
Thank you for your time. As always, ask for any more information, and I will reply as soon as possible.
Edit: I have managed to fix it! I used the ROBLOX animation script so it will detect when the player moves!