Animations in public games are very strange

Roblox studio:
robloxapp-20241129-2234098.wmv (1.6 MB)

Public game:
robloxapp-20241129-2235078.wmv (1.5 MB)


local T1 = group:WaitForChild("BadTouch1")
local T2 = group:WaitForChild("BadTouch2")

local Arm = group:WaitForChild("EnemyLongArmCutscene")
local cube = Arm:WaitForChild("Cube.001")
local humanoid = Arm:FindFirstChild("Humanoid") 
local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)

local animationId = "rbxassetid://83625405610602" 
local animationId2 = "rbxassetid://126781645605788"
local animation = Instance.new("Animation")
local animation2 = Instance.new("Animation")

animation.AnimationId = animationId
animation2.AnimationId = animationId2

local animationTrack = animator:LoadAnimation(animation)
local animationTrack2 = animator:LoadAnimation(animation2)


local function playAnimation2()
	if not animationTrack.IsPlaying then
		animationTrack2:Play()
		animationTrack2:AdjustSpeed(1)
	end
end

local ventsound = cube:WaitForChild("Metal 50 Gallon Drum Rolling On Edge 2 (SFX)")

ventsound:Play()
playAnimation2()

local function playAnimation()
	if not animationTrack.IsPlaying then
		animationTrack:Play()
		animationTrack:AdjustSpeed(1)
	end
end

local debounce = false

animationTrack2.Ended:Connect(function()
	playAnimation()

end)

local soundWater = cube:WaitForChild("Watermelon Splat 1 (SFX)")
local handsound = cube:WaitForChild("Spider Footsteps 3 (SFX)")


local replicage = game.ReplicatedStorage
local event = replicage:WaitForChild("Monster_AI"):WaitForChild("Jumpscare")
local npc = workspace:WaitForChild("LongArmJumpscare")
local cube = npc["Cube.001"].JumpscareSound








animationTrack:GetMarkerReachedSignal("FirstTouch"):Connect(function()
	T1.CanTouch = true
	T2.CanTouch = false
	handsound:Play()
	print("T1")
end)


animationTrack:GetMarkerReachedSignal("SecondTouch"):Connect(function()
	T2.CanTouch = true
	T1.CanTouch = false
	soundWater:Play()
	print("T2")
end)

animationTrack:GetMarkerReachedSignal("Leave"):Connect(function()
	T2.CanTouch = false
	T1.CanTouch = false
	print("Leave")
	task.wait(1)
	animationTrack:AdjustSpeed(0)
end)


local d = false


local function isPlayer(part)
	local character = part.Parent
	if character and character:FindFirstChild("Humanoid") then
		return game.Players:GetPlayerFromCharacter(character)
	end
	return nil
end

local debounce = false

local function handleTouch(touchPart, event, npc, cube)
	touchPart.Touched:Connect(function(hit)
		local player = isPlayer(hit)
		if player and not debounce then
			debounce = true
			print(touchPart.Name .. " TOUCHED by", player.Name)
			task.wait(0.5)
			debounce = false
			event:FireClient(player, npc)
			cube:Play()
			local character = player.Character
			if character and character:FindFirstChild("Humanoid") then
				character.Humanoid.Health = 0
			end
		end
	end)
end

handleTouch(T1, event, npc, cube)
handleTouch(T2, event, npc, cube)

I’m not really sure what cause all of this, it also happen to some of my animation too.

i havent checked ur files but uh try changing the priority?

oh my I didn’t think about that

ye if its an action, probably getting ovverrided by walking running jumping or idle anims

I set the second animation to action2 but the result still the same. do you have any idea what cause this?

or maybe I did something wrong but I’m not really sure.

are they still strange, maybe set both to action

yeah, they are still the same, I did set second animation to Action2, the first one is Action

After delete second animation track, the animation start working again . I think it probably because secondtrack also playing(???) I’m not sure but overall it working now, I will try to do something about it .

Final solution:

local group = script.Parent

local T1 = group:WaitForChild(“BadTouch1”)
local T2 = group:WaitForChild(“BadTouch2”)

local Arm = group:WaitForChild(“EnemyLongArmCutscene”)
local cube = Arm:WaitForChild(“Cube.001”)
local humanoid = Arm:FindFirstChild(“Humanoid”)
local animator = humanoid:FindFirstChild(“Animator”) or Instance.new(“Animator”, humanoid)

local animationId1 = “rbxassetid://126781645605788”
local animationId2 = “rbxassetid://97034185539368”

local animation1 = Instance.new(“Animation”)
animation1.AnimationId = animationId1
local animationTrack1 = animator:LoadAnimation(animation1)

local animation2 = Instance.new(“Animation”)
animation2.AnimationId = animationId2
local animationTrack2 = animator:LoadAnimation(animation2)

local function playAnimation1()
if not animationTrack1.IsPlaying then
animationTrack1:Play()
animationTrack1:AdjustSpeed(1)
end
end

local function playAnimation2()
animationTrack1.Stopped:Connect(function()
if not animationTrack2.IsPlaying then
animationTrack2:Play()
animationTrack2:AdjustSpeed(1)
end
end)
end

local ventsound = cube:WaitForChild(“Metal 50 Gallon Drum Rolling On Edge 2 (SFX)”)
ventsound:Play()

playAnimation1()
playAnimation2()

local soundWater = cube:WaitForChild(“Watermelon Splat 1 (SFX)”)
local handsound = cube:WaitForChild(“Spider Footsteps 3 (SFX)”)

local replicage = game.ReplicatedStorage
local event = replicage:WaitForChild(“Monster_AI”):WaitForChild(“Jumpscare”)
local npc = workspace:WaitForChild(“LongArmJumpscare”)
local cube = npc[“Cube.001”].JumpscareSound

animationTrack2:GetMarkerReachedSignal(“FirstTouch”):Connect(function()
T1.CanTouch = true
T2.CanTouch = false
handsound:Play()
print(“T1”)
end)

animationTrack2:GetMarkerReachedSignal(“SecondTouch”):Connect(function()
T2.CanTouch = true
T1.CanTouch = false
soundWater:Play()
print(“T2”)
end)

animationTrack2:GetMarkerReachedSignal(“Leave”):Connect(function()
T2.CanTouch = false
T1.CanTouch = false
print(“Leave”)
task.wait(1)
animationTrack2:AdjustSpeed(0)
end)

local d = false

local function isPlayer(part)
local character = part.Parent
if character and character:FindFirstChild(“Humanoid”) then
return game.Players:GetPlayerFromCharacter(character)
end
return nil
end

local debounce = false

local function handleTouch(touchPart, event, npc, cube)
touchPart.Touched:Connect(function(hit)
local player = isPlayer(hit)
if player and not debounce then
debounce = true
print(touchPart.Name … " TOUCHED by", player.Name)
task.wait(0.5)
debounce = false
event:FireClient(player, npc)
cube:Play()
local character = player.Character
if character and character:FindFirstChild(“Humanoid”) then
character.Humanoid.Health = 0
end
end
end)
end

handleTouch(T1, event, npc, cube)
handleTouch(T2, event, npc, cube)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.