Skip to content

Add speed and looping control to :animation (#1924)#2128

Open
thatgato wants to merge 5 commits into
Epix-Incorporated:masterfrom
thatgato:enhance-animation-cmd
Open

Add speed and looping control to :animation (#1924)#2128
thatgato wants to merge 5 commits into
Epix-Incorporated:masterfrom
thatgato:enhance-animation-cmd

Conversation

@thatgato
Copy link
Copy Markdown
Contributor

@thatgato thatgato commented May 9, 2026

Adds two new optional arguments to the :animate command.

[speed] (default: 1): Controls the animation speed
[isLooped?] (default: false): Controls whether the animation track should be loaded as a looped one, or not

PoF:

2026-05-09.16-27-41.mp4

Argument validation:
speed should be a number, otherwise the assertion will throw
the looped argument only cares about "true" and "1"
in all other cases, it will default to false

2026-05-09.16-28-28.mp4

thatgato added 2 commits May 9, 2026 16:18
Added optional arguments to the :animation command.

New optional arguments:
speed (default 1); isLooped (default false)

Also updated the description of the command to be more straightforward
@thatgato
Copy link
Copy Markdown
Contributor Author

thatgato commented May 9, 2026

Closes issue #1924 if merged

Forgot to put tonumber() on it

Although, it was working fine without it
But just to be consistent, since Functions.PlayAnimation expects a number there.
Comment thread MainModule/Server/Commands/Fun.luau Outdated
Comment on lines +4374 to +4377
assert(tonumber(args[2]), `{tostring(args[2])} is not a valid ID!`)
if args[3] then
assert(tonumber(args[3]), `{tostring(args[3])} is not a valid speed!`)
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should replace this with a more efficient piece of code.

Suggested change
assert(tonumber(args[2]), `{tostring(args[2])} is not a valid ID!`)
if args[3] then
assert(tonumber(args[3]), `{tostring(args[3])} is not a valid speed!`)
end
local id = assert(tonumber(args[2]), `{tostring(args[2])} is not a valid ID!`)
local speed = args[3] and assert(tonumber(args[3]), `{tostring(args[3])} is not a valid speed!`) or nil

Comment thread MainModule/Server/Commands/Fun.luau Outdated

for _, v in service.GetPlayers(plr, args[1]) do
Functions.PlayAnimation(v , args[2])
Functions.PlayAnimation(v , args[2], tonumber(args[3]), isLooped)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Functions.PlayAnimation(v , args[2], tonumber(args[3]), isLooped)
Functions.PlayAnimation(v , id, speed, isLooped)

Comment thread MainModule/Server/Commands/Fun.luau Outdated
Comment on lines +4378 to +4384

local isLooped = false

-- TODO Possibly add a helper function for parsing string into bool?
if args[4] == "true" or args[4] == "1" then
isLooped = true
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local isLooped = false
-- TODO Possibly add a helper function for parsing string into bool?
if args[4] == "true" or args[4] == "1" then
isLooped = true
end
local isLooped = args[4] == "true" or args[4] == "1"or false -- TODO Possibly add a helper function for parsing string into bool?

Copy link
Copy Markdown
Collaborator

@joritochip joritochip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If looped arg isn't present should it should not set Looped on the animation track at all so that the animation's default looped value is used as the fallback

@thatgato
Copy link
Copy Markdown
Contributor Author

If looped arg isn't present should it should not set Looped on the animation track at all so that the animation's default looped value is used as the fallback

Made the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants