Skip to content

Commit

Permalink
Enhanced "characteraudio" command
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-police authored Dec 12, 2021
1 parent 8ea0ff8 commit 8ee0041
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions MainModule/Server/Commands/Moderators.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4673,14 +4673,31 @@ return function(Vargs, env)
CharacterAudio = {
Prefix = Settings.Prefix;
Commands = {"charaudio", "charactermusic", "charmusic"};
Args = {"player", "audioId"};
Args = {"player", "audioId", "volume", "loop(true/false)", "pitch"};
Description = "Lets you place an audio in the target's character";
AdminLevel = "Moderators";
Function = function(plr: Player, args: {string})
assert(args[1], "Missing player name")
assert(args[2] and tonumber(args[2]), "Missing or invalid AudioId")

local volume = tonumber(args[3]) or 1
local looped = args[4]
local pitch = tonumber(args[5]) or 1

if (looped) then
if looped == "true" or looped == "1" then
looped = true
else
looped = false
end
else
looped = true -- should be on by default
end

local audio = service.New("Sound", {
Looped = true;
Volume = volume;
Looped = looped;
Pitch = pitch;
Name = "ADONIS_AUDIO";
SoundId = "rbxassetid://"..args[2];
})
Expand All @@ -4690,6 +4707,13 @@ return function(Vargs, env)
local rootPart = char and char:FindFirstChild("HumanoidRootPart")
if rootPart then
local new = audio:Clone()
print(new.TimeLength)
if (looped == false) then
new.Ended:Connect(function()
new:Destroy() -- Destroy character audio after sound is finished if loop is off.
end)
end

new.Parent = rootPart
new:Play()
end
Expand Down

0 comments on commit 8ee0041

Please sign in to comment.