#When I press 2, my T.rex stops

1 messages · Page 1 of 1 (latest)

dawn crown
#

Whenever I press number 2, my t rex just stops inplace. I used Chatgpt for the scripts but it couldn't figure out the problem.

#

This happens when I'm holding w + shift to run. It just stops when I press 2

gritty vector
#

What's the script?

dawn crown
#

Here's the movement code

#

Lemme get the rest

#

Here's the calls

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")

-- Roar state
local isRoaring = false

-- === Broadcast Roar ===
local broadcastAnim = Instance.new("Animation")
broadcastAnim.AnimationId = "rbxassetid://123552972399365"

local broadcastSound = Instance.new("Sound")
broadcastSound.SoundId = "rbxassetid://134725024064440"
broadcastSound.Volume = 1
broadcastSound.Name = "BroadcastRoarSound"
broadcastSound.Parent = hrp

local broadcastTrack = humanoid:LoadAnimation(broadcastAnim)
broadcastTrack.Priority = Enum.AnimationPriority.Action
broadcastTrack.Looped = false

-- === Aggro Roar ===
local aggroAnim = Instance.new("Animation")
aggroAnim.AnimationId = "rbxassetid://117503416295803"

local aggroSound = Instance.new("Sound")
aggroSound.SoundId = "rbxassetid://126707578316377"
aggroSound.Volume = 1
aggroSound.Name = "AggroRoarSound"
aggroSound.Parent = hrp

local aggroTrack = humanoid:LoadAnimation(aggroAnim)
aggroTrack.Priority = Enum.AnimationPriority.Action
aggroTrack.Looped = false

-- === Roar Trigger Handler ===
local function playRoar(track, sound)
if isRoaring then return end
isRoaring = true

sound:Play()
track:Play()

track.Stopped:Connect(function()
    isRoaring = false
end)

end

-- === Input Handler ===
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed or isRoaring then return end

if input.KeyCode == Enum.KeyCode.One then
    playRoar(broadcastTrack, broadcastSound)
elseif input.KeyCode == Enum.KeyCode.Two then
    playRoar(aggroTrack, aggroSound)
end

end)

dawn crown
rare tinselBOT
#

studio** You are now Level 1! **studio

gritty vector
#

So the roar animation doesn't play

#

I think i found the issue

dawn crown
#

Nope, it just freezes when I press 2 while holding w and shift

dawn crown
gritty vector
#

The aggroTrack is being loaded by the humanoid, it needs to be loaded by humanoid.Animator

#

So basically: local aggroTrack = humanoid.Animator:LoadAnimation(aggroAnim)

dawn crown
#

Alr, I'll try it

#

Sorry if I don't understand much. I'm not much of a coding guy.

dawn crown
#

Which script?

#

The broadcastaggro? (aka calls)

gritty vector
dawn crown
#

Ah

#

Alr lemme try

#

Uh, it didn't work.

#

Idk if I wrote it correctly

#

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")

-- Roar state
local isRoaring = false

-- === Broadcast Roar ===
local broadcastAnim = Instance.new("Animation")
broadcastAnim.AnimationId = "rbxassetid://123552972399365"

local broadcastSound = Instance.new("Sound")
broadcastSound.SoundId = "rbxassetid://134725024064440"
broadcastSound.Volume = 1
broadcastSound.Name = "BroadcastRoarSound"
broadcastSound.Parent = hrp

local broadcastTrack = humanoid:LoadAnimation(broadcastAnim)
broadcastTrack.Priority = Enum.AnimationPriority.Action
broadcastTrack.Looped = false

-- === Aggro Roar ===
local aggroAnim = Instance.new("Animation")
aggroAnim.AnimationId = "rbxassetid://117503416295803"

local aggroSound = Instance.new("Sound")
aggroSound.SoundId = "rbxassetid://126707578316377"
aggroSound.Volume = 1
aggroSound.Name = "AggroRoarSound"
aggroSound.Parent = hrp

local aggroTrack = humanoid.Animator:LoadAnimation(aggroAnim)
aggroTrack.Priority = Enum.AnimationPriority.Action
aggroTrack.Looped = false

-- === Roar Trigger Handler ===
local function playRoar(track, sound)
if isRoaring then return end
isRoaring = true

sound:Play()
track:Play()

track.Stopped:Connect(function()
    isRoaring = false
end)

end

-- === Input Handler ===
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed or isRoaring then return end

if input.KeyCode == Enum.KeyCode.One then
    playRoar(broadcastTrack, broadcastSound)
elseif input.KeyCode == Enum.KeyCode.Two then
    playRoar(aggroTrack, aggroSound)
end

end)

#

@gritty vector

gritty vector
#

Yep, that's right

#

Did it work?

dawn crown
#

Note: Even without the calls script. It would still stop the rex when I hold shift and w

#

I think it within the movement code

dawn crown
gritty vector
#

But is the animation playing fine?

dawn crown
#

Hold on let me record the video real quick

rare tinselBOT
#

studio** You are now Level 2! **studio

gritty vector
#

Wait, was the roar animation published by you?

dawn crown
#

wdym?

gritty vector
#

The roar animation you made, when you press 2

#

If it doesn't play maybe it can break

dawn crown
#

I bought it from someone

gritty vector
#

Ohh, that's the issue

#

I've had the same issue because roblox only allows animations to work in studio if you publish them in your place

dawn crown
#

Hold on, just to make this easier. Can we go into private vc so I can stream it to you?

gritty vector
#

And then i made one code for a mini cutscene and it did not work because the animation did not played since the id of it was uploaded by a friend of mine

gritty vector
#

Sorry i can't rn

dawn crown
#

Oh alr

#

But is there a fix to the issue?

gritty vector
#

Well, if you didn't upload the animation, try uploading it and copy the id of the animation

#

And then you would need to paste the animation id into the id properties of the animation

#

And then it might work

gritty vector
dawn crown
#

I thought you meant where I got the animations from

#

My bad

#

Yes, I have uploaded the animations provided in the model and published them into my inventory

#

@gritty vector

#

But the animations were purchased from someone as I said earlier

#

They were provided in a model

gritty vector
#

And was this place created by you?

#

The one you are doing the dino

dawn crown
#

Yes

dawn crown
earnest shadow
#

cool ass t-rex tho

dawn crown