Hi, I have made a clown mask and want to know how I can script it to play audio file every x amount of minutes.
I have made an accessory and mask is wearable, i just need to be able to play an audio file ID every so often while the mask is being worn. How can I script this?
I think what you can do is insert a script that has a loop that repeatedly waits a few minutes and then play the audio. Make the script disable Then, in another script, probably in the Character which you can add via a script in StarterCharacterScripts, you can use the ChildAdded event on the Character to detect if something got, added, and if it was the mask accessory, enable the script. That’s atleast how I would do it when it’s worn
You assign in the Sound itself via the Explorer. Get the id you want to use, click on the Sound i nthe explorer, go into its property and click on SoundId, paste the ID and press enter
I’m not sure, but I don’t think it should be anything to worry about for @pilers22, but if they want, they could research and find a Custom Wait which I recall was in the DevForum
Not using a while true do wouldn’t work in this case since OP specifies he wants it to play a sound after 200 seconds (it could be a simple sound effect like those Accessories that make a sound). If we used Looped and Playing, it will repeatedly play the sound even if 200 seconds haven’t passed since it will the sound again when the audio has finished. This is the simplest way to achieve what he wanted, a sound that plays every 200 seconds
Haha, that’s okay! Sometimes we skim through what we’re reading and forget to notice the important details. But yea, your idea would work better if it was an Accessory that played music, but he never really specified, but if made my answer as the solution, then it was most definitely just a sound effect
exactly. I was unable to place the script in the mask accessory, as it did not work. But i ended up putting it in workspace. Maybe that would be funnier for what i am doing…i have 2 sounds, one is a background music which i renamed to BG and my sound1 (while looped) i couldnt figure out why sound isnt playing with the mask
i have several scripts on the last. It is supposed to be for game pass, whoever has the mask it will make a sound. It just wouldnt play. I put it “script” under the handle, and tried it as a parent of the accessory (which there already is a script) I also tried adding it the scripts to no avail
local MarketplaceService = game:GetService('MarketplaceService')
local GAMEPASSID = 15193367
local function AddHatToCharacter(Character)
-- Run code to add hat.
script:FindFirstChildOfClass('Accessory'):Clone().Parent = Character
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(Player, GamePassId, Purchased)
if Purchased then -- They actually bought it, and didn't click 'Cancel'
if GamePassId == GAMEPASSID then -- It's the hat gamepass
Player.CharacterAdded:Connect(function(Character)
AddHatToCharacter(Character)
end)
if Player.Character then
AddHatToCharacter(Player.Character)
end
end
end
end)
game:GetService('Players').PlayerAdded:Connect(function(Player)
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GAMEPASSID) then
Player.CharacterAdded:Connect(function(Character)
AddHatToCharacter(Character)
end)
end
end)