#ANIMATIONS AAAAAH

172 messages · Page 1 of 1 (latest)

deep mist
#

local Player = game.Players.LocalPlayer
local Character = Player.Character
local UIS = game:GetService('UserInputService')
local Players = game:GetService("Players")
local humanoid, char, player, rootPart, mouse, cam = nil, nil, nil, nil, nil, workspace.CurrentCamera
local anims = {}
local currentAnim = nil
--idle anim
script.Parent.Equipped:Connect(function()
humanoid = script.Parent.Parent.Humanoid
player= game.Players:GetPlayerFromCharacter(script.Parent.Parent)
char = script.Parent.Parent
rootPart= humanoid.RootPart
mouse= player:GetMouse()
anims.idle = humanoid:LoadAnimation(script.IdleAnim)
currentAnim = anims.idle
currentAnim:Play()
end)
--walk anim
script.Parent.Unequipped:Connect(function()
if currentAnim then
currentAnim:Stop()
currentAnim = nil
end
end)

UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.W and script.Parent.Parent == Player then
Character.Humanoid.WalkSpeed = 8
Character.Humanoid.JumpHeight = 0
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://98737670948083'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
else
task.wait()

end

end)

UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
Character.Humanoid.WalkSpeed = 16
Character.Humanoid.JumpHeight = 7.2
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://98737670948083'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Stop()
end
end)

quick phoenix
#

pls

deep mist
#

how

quick phoenix
deep mist
#
local Player = game.Players.LocalPlayer
local Character = Player.Character
local UIS = game:GetService('UserInputService')
local Players = game:GetService("Players")
local humanoid, char, player, rootPart, mouse, cam = nil, nil, nil, nil, nil, workspace.CurrentCamera
local anims = {}
local currentAnim = nil
--idle anim
script.Parent.Equipped:Connect(function()
    humanoid = script.Parent.Parent.Humanoid
    player= game.Players:GetPlayerFromCharacter(script.Parent.Parent)
    char = script.Parent.Parent
    rootPart= humanoid.RootPart
    mouse= player:GetMouse()
    anims.idle = humanoid:LoadAnimation(script.IdleAnim)
    currentAnim = anims.idle
    currentAnim:Play()
end)
--walk anim
script.Parent.Unequipped:Connect(function()
    if currentAnim then
        currentAnim:Stop()
        currentAnim = nil
    end
end)

UIS.InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.W and script.Parent.Parent == Player then
        Character.Humanoid.WalkSpeed = 8
        Character.Humanoid.JumpHeight = 0
        local Anim = Instance.new('Animation')
        Anim.AnimationId = 'rbxassetid://98737670948083'
        PlayAnim = Character.Humanoid:LoadAnimation(Anim)
        PlayAnim:Play()
    else
        task.wait()
        
    end
end)

UIS.InputEnded:connect(function(input)
    if input.KeyCode == Enum.KeyCode.W then
        Character.Humanoid.WalkSpeed = 16
        Character.Humanoid.JumpHeight = 7.2
        local Anim = Instance.new('Animation')
        Anim.AnimationId = 'rbxassetid://98737670948083'
        PlayAnim = Character.Humanoid:LoadAnimation(Anim)
        PlayAnim:Stop()
    end
end)
quick phoenix
#

put your entire code inside that

deep mist
#

err

quick phoenix
#

```

#

those

deep mist
#

can you paste me the ''' please

#

thanks

quick phoenix
#

theyre below your escape

#

Also just edit msg

#

dont send entire new flood

deep mist
#

i dont have escape

quick phoenix
#

its same as ~

deep mist
#

alright

quick phoenix
#

you were close

#

remove the apostrophe before lua

#

sick

deep mist
#

sorry for not knowing i usually only do vfx

quick phoenix
#

dw lol

#

u know u can declare variables within functions right

deep mist
#

yes

#

i made global variables

quick phoenix
#

so why u no do that

#

so when should the player be slower?

deep mist
#

when the tool is equipped

quick phoenix
#

Thats not what you're doing here

#

You are decreasing the speed when the player pressed W

deep mist
#

yeah

quick phoenix
#

not when u equip a tool

deep mist
#

but that works too right?

quick phoenix
#

Yea but that doesnt make it so it decreases when u equip a tool

deep mist
#

cuz the walkspeed won't be shown until i start actually walking

quick phoenix
#

U can just connect functions to .Equipped and .Unequipped on the tool

#

In there u can edit the walkspeed

#

Where is this script located? And whats the reason for the global variables

deep mist
#

the script is loaded in the tool

#

which is in starterplayer

#

starterpack*

quick phoenix
#

okay. Thats client sided and gets replicated into each player. You dont need anything with the inputbegan i dont think. Just edit the speed and jumppower in the Equipped and .Unequipped funcs

deep mist
#

uh

#

can youhelp me a bit here please

#

i'm a bit lost

quick phoenix
#
script.Parent.Equipped:Connect(function()
  humanoid = script.Parent.Parent:WaitForChild("Humanoid") -- Im just assuming this works
  humanoid.WalkSpeed = 8
  humanoid.JumpHeight = 0
  -- rest of code wherever
end)

script.Parent.Unequipped:Connect(function()
    humanoid = script.Parent.Parent:WaitForChild("Humanoid") -- Im just assuming this works
  humanoid.WalkSpeed = 16
  humanoid.JumpHeight = 7.2
  -- rest of code wherever
end)
deep mist
#

thank you

gleaming glenBOT
#

studio** You are now Level 6! **studio

quick phoenix
#

np

#

also since its a local script u can get the humanoid much easier

local char = game.Players.LocalPlayer.Character
local humanoid = char:WaitForChild("Humanoid")

This is more secure cause it guarantees that it finds the character, while script.Parent.Parent doesnt really guarantee that (even though it should still always be correct)

#

Its just more secure lets leave it at that

deep mist
#

wait

#

i already got the Idle animation

#

I just want to make it so that when I press W the animation plays

quick phoenix
#

always when u press W?

deep mist
#

well i plan on making 4 different animations that each have different animations

#

i want to make it so that when you equip it u cant jump

quick phoenix
#

When you equip the tool that u cant jump?

deep mist
#

yeah that's easy enough though

quick phoenix
#

Yea u should have that now

#

After adding what I sent

#

Then after that what do you need?

deep mist
#

im changing the script

quick phoenix
#

okay

deep mist
#

wait

#

do i keep the local uis.inputbegan stuff

#

or nah

quick phoenix
#

Not for the walkspeed and jumpheight no

deep mist
#

this doesn't work

#

ok this is the new script

#

the walkspeed stays at 8 when unequipping

quick phoenix
#

okay

#

so

deep mist
#

new script

#

holy shit

#

wtf

#
local Player = game.Players.LocalPlayer
local Character = Player.Character
local UIS = game:GetService('UserInputService')
local Players = game:GetService("Players")
local humanoid, char, player, rootPart, mouse, cam = nil, nil, nil, nil, nil, workspace.CurrentCamera
local anims = {}
local currentAnim = nil

--idle 
script.Parent.Equipped:Connect(function()
    humanoid = script.Parent.Parent.Humanoid
    humanoid.JumpPower = 0
    player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
    char = script.Parent.Parent
    rootPart = humanoid.RootPart
    mouse = player:GetMouse()
    anims.idle = humanoid:LoadAnimation(script.IdleAnim)
    currentAnim = anims.idle
    currentAnim:Play()
end)

script.Parent.Unequipped:Connect(function()
    if currentAnim then
        currentAnim:Stop()
        currentAnim = nil
    end
end)
--walk 

script.Parent.Equipped:Connect(function()
            humanoid = script.Parent.Parent:WaitForChild("Humanoid")
            humanoid.WalkSpeed = 8
            humanoid.JumpHeight = 0
            -- rest of code wherever
        
UIS.InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.W and script.Parent.Parent == Player then
        
        local Anim = Instance.new('Animation')
        Anim.AnimationId = 'rbxassetid://98737670948083'
        PlayAnim = Character.Humanoid:LoadAnimation(Anim)
        PlayAnim:Play()
    else
        task.wait()

        end
    end)
end)

script.Parent.Unequipped:Connect(function()
    humanoid = script.Parent.Parent:WaitForChild("Humanoid") 
    humanoid.WalkSpeed = 16
    humanoid.JumpHeight = 7.2
    -- rest of code wherever
        
UIS.InputEnded:connect(function(input)
    if input.KeyCode == Enum.KeyCode.W then
        
            local Anim = Instance.new('Animation')
            Anim.AnimationId = 'rbxassetid://98737670948083'
            PlayAnim = Character.Humanoid:LoadAnimation(Anim)
            PlayAnim:Stop()
        end
    end)
end)
#

ok so the error i'm getting is

quick phoenix
#

Yea okay

#

Its cause you reference incorrectly

quick phoenix
deep mist
#

tysm

#

it works

quick phoenix
#

nws

deep mist
#

ok so uh

#

its still playing the idle animation when I start walking

deep mist
# quick phoenix nws

also the other weird thing is that it seems to be that the walking anim is not playing at all

covert dew
#

put the loadAnimation outside the uis and play/stop in uis

#

also why are you doing this

local humanoid, char, player, rootPart, mouse, cam = nil, nil, nil, nil, nil, workspace.CurrentCamera
local anims = {}
local currentAnim = nil

pretty sure you can remove this except for cam

deep mist
#

i'll try

#
local Player = game.Players.LocalPlayer
local Character = Player.Character
local UIS = game:GetService('UserInputService')
local Players = game:GetService("Players")
local humanoid, char, player, rootPart, mouse, cam = nil, nil, nil, nil, nil, workspace.CurrentCamera
local char = game.Players.LocalPlayer.Character
local anims = {}
local currentAnim = nil
script.Parent.Equipped:Connect(function()
    humanoid = script.Parent.Parent.Humanoid
    humanoid.JumpPower = 0
    player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
    char = script.Parent.Parent
    rootPart = humanoid.RootPart
    mouse = player:GetMouse()
    anims.idle = humanoid:LoadAnimation(script.IdleAnim)
    currentAnim = anims.idle
    currentAnim:Play()
end)
script.Parent.Unequipped:Connect(function()
    if currentAnim then
    currentAnim:Stop()
    currentAnim = nil
    end
end)
script.Parent.Equipped:Connect(function()
    
    local Character = game.Players.LocalPlayer.Character
    local humanoid = char:WaitForChild("Humanoid")            humanoid.WalkSpeed = 8
        humanoid.JumpHeight = 0
local Anim=Instance.new('Animation')  
Anim.AnimationId ='rbxassetid://120674075556248'    
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
UIS.InputBegan:connect(function(input)
    
    if input.KeyCode == Enum.KeyCode.W and script.Parent.Parent == Player then
        PlayAnim:Play()        
        end
    end)
end)

script.Parent.Unequipped:Connect(function()
    local Character = game.Players.LocalPlayer.Character
    local humanoid = char:WaitForChild("Humanoid")
    humanoid.WalkSpeed = 16
    humanoid.JumpHeight = 7.2
    local Anim = Instance.new('Animation')
    Anim.AnimationId = 'rbxassetid://120674075556248'
    PlayAnim = Character.Humanoid:LoadAnimation(Anim)
UIS.InputEnded:connect(function(input)
    if input.KeyCode == Enum.KeyCode.W then        
            PlayAnim:Stop()
        end
    end)
end)
#

new script

#

still doesn't work

covert dew
#

alr wait

deep mist
#

okay

covert dew
#

here try this script

local UIS = game:GetService("UserInputService")

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local humAnimator = hum:WaitForChild("Animator")

local idleAnim = humAnimator:LoadAnimation(script:WaitForChild("IdleAnim"))
local playAnim = humAnimator:LoadAnimation(script:WaitForChild("")) -- put your playAnim under script rbxassetid://120674075556248

local tool = script.Parent

local function equipped()
    hum.JumpHeight = 0
    
    idleAnim:Play()
end

local function unequipped()
    idleAnim:Stop()
    
    hum.JumpHeight = 7.2
end

local function inputBegan(input, gp)
    if gp then return end
    if input.KeyCode == Enum.KeyCode.W then
        playAnim:Play()
    end
end

local function inputEnded(input, gp)
    if gp then return end
    if input.Keycode == Enum.KeyCode.W then
        playAnim:Stop()
    end
end


tool.Equipped:Connect(equipped)
tool.Unequipped:Connect(unequipped)

UIS.InputBegan:Connect(inputBegan)
UIS.InputEnded:Connect(inputEnded)
#

cleaned up a bunch of redundant variables, loaded animations outside functions and used animator instead of humanoid

deep mist
#

Alr

#

Keycode is not a valid member of InputObject "InputObject"

covert dew
#

mb its KeyCode

#

typo

deep mist
#

no errors but walk anim not playing

covert dew
#

is your walk anim a custom one?

deep mist
#

yes

covert dew
#

did you put the animation under the script

deep mist
#

yes

#

i set the priority to action

covert dew
#

set it to movement

deep mist
#

ok its fixed

#

the anim plays when i press w and haven't got the tool equipped

covert dew
#

mb forgot to add a check

#

just put and if tool.Parent == char as a check

#

on both UIS functions

deep mist
#

damn scripting is tricky

#

vfx is so much easier lmao

covert dew
#

i mean it gets easier the more you mess around with scripts and stuff

#

if you want to learn basics BrawlDev has some good tutorials

deep mist
#

i looked at the full 18 episodes

covert dew
#

imo best way to learn is making a game and solving problems along the way

deep mist
#

thats what i'm doing rn

deep mist
#

should I just stop all anims when unequipping to avoid this?

covert dew
#

remove the check on inputEnded

deep mist
#

i was thinking of doing something like this

#

for i,v in pairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop() end

#

oh ok

covert dew
deep mist
#

okay

#

I think the bug is fixed now

covert dew
#

alr cool

deep mist
#

yo metals

gleaming glenBOT
#

studio** You are now Level 7! **studio

deep mist
#

can you help me again please

covert dew
#

sure

deep mist
#

I just added a punch animation but I don't know how to not mix the animations up

#

heres my code right now

#

hold on its getting too long

#

so the problem i'm having right now is that the punch anim won't work properly if two anims are running at the same time but I don't know how to only run the punch animation alone

#

and then restart them

covert dew
#

put the punch anim priority to action 1 - 4 depending on how important it is

deep mist
#

so like

covert dew
#

also if youre trying to detect if the mouse is held use RunService instead of a while loop

deep mist
#

JabAnim.AnimationPriority = Action4

#

is that gonna work

covert dew
#

i'd change it in the animation editor

#

ive never changed it using scripts tbh

deep mist
#

how do I fix this lmao i've never used the roblox animator b4

#

the publish to roblox tab isn't there

covert dew
#

click the 3 dots on the left for options

deep mist
#

there are none

#

ill restart ts

covert dew
gleaming glenBOT
#

studio** You are now Level 7! **studio

covert dew
#

there should be 3 dots on the left side

deep mist
#

yeah that doesn't appear for me

#

for some reason

covert dew
#

bruh

deep mist
#

alright its working now

covert dew
#

nice

deep mist
#

now I need to make a hitbox

#

and a debounce time

covert dew
#

also waitForChild is not needed for instances under replicated storage

#

and use task.wait() instead of wait()

deep mist
#

oh isnt wait() depricated?