Hey, I need help with this animation. Whenever another animation plays it just completely loops even when its not toggled (shift to sprint) if anyone can help me I would appreciate it (Video Below)
Does this only happen when you get into the swamp while running? If so, stop all animations when the swamp animation ends. I can’t help you stop it completely because you haven’t shared the codes.
Yes it does. The code is
script.Parent.Touched:Connect(function(plr)
if plr.Parent:FindFirstChild("reds") then
local run = plr.Parent:FindFirstChild("reds")
wait()
run.Disabled = true
run.Animation:Stop()
wait(7)
run.Disabled = false
end
end)
You can try something like this;
script.Parent.Touched:Connect(function(plr)
if plr.Parent:FindFirstChild("reds") then
local run = plr.Parent:FindFirstChild("reds")
run:Stop()
end
end)
When player toggle run again, It will already play.
“run” is the LocalScript thats runs the animation.
Im really not sure the problem but you not need to disable script. Just stop animation.
I disable it so when you step into the puddle you cant hold shift to run and not just run out of the puddle
In my opinion, this method is not very stable. You can create a BoolValue and have the running animation not play when it is false.
When the sinking animation runs, set this value to false and stop animation.
That’s all I can help with, good luck
You can try this:
local Debounce = {}
script.Parent.Touched:Connect(function(plr)
if plr.Parent:FindFirstChild("reds") and not Debounce[plr] == true then
Debounce[plr] = true
local character = plr.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")
for _, track in ipairs(humanoid:GetPlayingAnimationTracks()) do
track:Stop()
end
delay(2, function()
Debounce[plr] = nil
end)
end
end)
Edit: You are using .Touched event and the correct argument name is “hit” and not plr.
reds is the Running local script
There is no need to disable the running local script
But I need it to stop whenever you run into the puddle so you cant set walkspeed to 25 when your walkspeed is needed to be 0
Can you show the running local script ?
local ts = game:GetService('TweenService')
local cas = game:GetService('ContextActionService')
local cam = workspace.CurrentCamera
local humanoid = script.Parent:WaitForChild("Humanoid",3)
local sprintAnim = humanoid:LoadAnimation(script:WaitForChild("SprintAnim"))
local isSprinting, ifSprintAnimPlaying = false, false
local FOVIn = ts:Create(
cam,
TweenInfo.new(.5),
{FieldOfView = 71}
)
local FOVOut = ts:Create(
cam,
TweenInfo.new(.5),
{FieldOfView = 70}
)
local function sprint(Type)
if Type == "Begin" then
isSprinting = true
humanoid.WalkSpeed = 22.5
elseif Type == "Ended" then
isSprinting = false
humanoid.WalkSpeed = 16
end
end
cas:BindAction("Sprint", function(_,inputState)
if inputState == Enum.UserInputState.Begin then
sprint("Begin")
else
sprint("Ended")
end
end, true, Enum.KeyCode.LeftShift)
cas:SetTitle("Sprint","Sprint")
cas:SetPosition("Sprint",UDim2.new(1, -70, 0, 10))
game:GetService("RunService").RenderStepped:Connect(function()
if isSprinting and humanoid.MoveDirection.Magnitude > 0 then
FOVIn:Play()
if humanoid:GetState() == Enum.HumanoidStateType.Running or humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics then
if not ifSprintAnimPlaying then
sprintAnim:Play()
ifSprintAnimPlaying = true
end
else
if ifSprintAnimPlaying then
sprintAnim:Stop()
ifSprintAnimPlaying = false
end
end
else
FOVOut:Play()
if ifSprintAnimPlaying then
sprintAnim:Stop()
ifSprintAnimPlaying = false
end
end
end)
here
You can try to add a remote event and when the player’s character touches the part it fire the client and you unbind the “sprint” action with the context action service and stop the running animation
Remember what you are doing, unbind the “sprint” action from the running local script and stop running animation
So I make the event. Then when touched fire the event? Whats that going to do
remote.OnClientEvent:Connect(function()
cas:UnbindAction("sprint")
if ifSprintAnimPlaying then
sprintAnim:Stop()
ifSprintAnimPlaying = false
end
end)
You can do something like this:
local Players = game:GetService("Players")
local Debounce = {}
local remote = -- Add the path
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") and not Debounce[Players:GetPlayerFromCharacter(hit.Parent)] == true then
local player = Players:GetPlayerFromCharacter(hit.Parent)
Debounce[player] = true
remote:FireClient(player)
end
end)
what would “cas” be? 30char30char