Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a script that plays an animation at a specific speed?

Asked by 2 years ago

I've tried everything I can and it doesn't work I changed the normal Roblox animation code so that if the WalkSpped is equal or more than WalkSpeed a different animation is played

local Players = game:GetService("Players") 
local runAnimation = "rbxassetid://8477846036" --Gets Animation

local function onCharacterAdded(character)
    local humanoid = character:WaitForChild("Humanoid") -- Gets humanoid

    local animateScript = character:WaitForChild("Animate") --
    local walkspeed = humanoid.WalkSpeed
    if walkspeed >= 25 then
        animateScript.run.RunAnim.AnimationId = runAnimation
    elseif walkspeed < 25 then
        --
    end
end

local function onPlayerAdded(player)
    player.CharacterAppearanceLoaded:Connect(onCharacterAdded) -- Connects onCharacterAdded when the CharacterApperanceLoaded is true
end

Players.PlayerAdded:Connect(onPlayerAdded) -- Connects onPlayerAdded to PlayersAdded idk

2 answers

Log in to vote
0
Answered by 2 years ago

I tried something else in the animation script but it won't work nor save

function onRunning(Speed)
    local runAnimation = "rbxassetid://8477846036"
    if Speed >= 25  then
        animTable[3][1][1] = runAnimation
    elseif Speed < 25 then

    else
        --function
    end
end

Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago
Edited 2 years ago

You need to check if the walkspeed changes, there's a built-in function named "GetPropertyChangedSignal" to get the event of it, example script (Edited to fix the issues):


local function OnCharacterAdded(chr) chr.Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function() local newSpeed = chr.humanoid.WalkSpeed if newSpeed >= 25 then chr.Animate.run.RunAnim.AnimationId = runId else -- Default walk animation end end) -- Get walkspeed change event, you can use this on other properties too end local function OnPlayerAdded(plr) plr.CharacterAdded:Connect(OnCharacterAdded) -- other stuff end game.Players.PlayerAddded:Connect(OnPlayerAdded)
0
When i use this script there is alot of variable errors and i dont know how to make the changes to make the variable NoahSegasonic 0 — 2y
0
@NoahSegasonic like what? enes223 327 — 2y
0
plr and humanoid NoahSegasonic 0 — 2y
0
I'm sorry I didn't notice, editing my answer now. enes223 327 — 2y

Answer this question