Looking for someone that can help me do this script, I cannot find a way to speed up an animation, which I want to put under the then
, but I cannot seem to find a way to get to the animation speed, can somebody help? The script just points out a specific player in a game.
local player = {"playername"}
local animation = game.Workspace.Script.Animation
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(chr)
for i = 1, #player do
if player[i] == plr.Name then
end
end
end)
end)
2 Likes
Are you trying to give each player an new animation then speed it up? Or take an existing animation and speed it up?
You can access animation speed by doing something like this:
local animationTrack = chr.Humanoid:LoadAnimation(animation)
function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:AdjustSpeed(speed)
animationTrack:Play()
end
playAnimationForDuration(animationTrack, duration/2) -- reduce duration by half
I’m trying to take an existing animation and speed it up for one player, thank you.
Alright, so in-between your if statement your probably going to want to start by cloning the animation then take that clone and make its parent = the character. Then load use the code I provided in the previous response.
1 Like
So does the script become a child of the character? How would it work if I’m trying to get a specific player to get the animation speed and nobody else?.
It just depends where it exists in your files. If the script is in “workspace” then its not going to move anywhere.
So this is a script for a friend, where exactly would I tell him to put the script under because its a custom emote script (/e emote), and he just wanted his to be 2* faster, so would I tell him to put it under players?
I think the best place for a script like this is in “ServerScriptService”, that way it’s easy to locate for editing later on. If you put it in players then it wont run at the start of your game.
1 Like
Quick question, where would the animationID go? I’m still a basic/beginner at scripting, wait nvm its the child of my script
dont know if its supposed to be there or not though
By code you can do it like this
animation.AnimationId = "http://www.roblox.com/asset/?id=507771019"
Just replace the last set of numbers on the string above.
So currently this is my script local player = {“Iifeform”}
local animation = game.Workspace.Script.Animation
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(chr)
for i = 1, #player do
if player[i] == plr.Name then
local animationTrack = chr.Humanoid:LoadAnimation(animation)
animation.AnimationId = "http://www.roblox.com/asset/?id=(animation id)"
function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:AdjustSpeed(2)
animationTrack:Play()
end
playAnimationForDuration(animationTrack, duration/2)
end
end
end)
end)
This is my current script that should work. It's placed in ServerScriptService.