I am trying to make it so when the player chats, a sound emits from the players character.
However for some reason the sounds that are supposed to be coming from the character are actually coming from the server even with the sounds being parented to the humanoid.
I have tried looking for answers, and I was told that I could parent the sound to something and that ROBLOX Studio would do the work on making it actually come from the thing I parented it to, this is not the case for some reason.
local rps = game:GetService("ReplicatedStorage")
local sounds = rps.sounds --this is a folder
local soundslistac= sounds.Accordion
local soundslistaccor1 = soundslistac.Accor1 -- 1 and 2 are a folder in the folder in the folder of sounds and actually contain sound instances
local soundslistaccor2 = soundslistac.Accor2
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local humanoid = char:FindFirstChild("Humanoid")
local copyofsfxac1 = sounds.Accordion.Accor1:Clone()
copyofsfxac1.Parent = humanoid -- im parenting the sound folder to the humanoid, so that should mean its emitting from the character?
local tableofsfx = copyofsfxac1:GetChildren()
player.Chatted:Connect(function(themessage)
local amountofletter = themessage.len(themessage)
if amountofletter < 5 then
print("1")
tableofsfx[math.random(1,15)]:Play() -- it doesn't play from the character :(
end
end)
end)
end)
Help is appreciated as I have been stuck on this for almost an entire day!
the sounds are playing just fine and they are in a folder in the characters humanoidrootpart when the game is loaded up, however it is not playing specifically from the character which i want it to do.
It turns out that the sound instances parents SPECIFICALLY have to be parented to the part that is playing the sound, no matter even if it is in a folder that is parented to the object you want to play it in.
Fixed code:
local rps = game:GetService("ReplicatedStorage")
local sounds = rps.sounds --this is a folder
local soundslistac= sounds.Accordion
local soundslistaccor1 = soundslistac.Accor1 -- 1 and 2 are a folder in the folder in the folder of sounds and actually contain sound instances
local soundslistaccor2 = soundslistac.Accor2
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local humanoid = char:FindFirstChild("HumanoidRootPart")
local copyofsfxac1 = sounds.Accordion.Accor1:Clone()
local tableofsfx = copyofsfxac1:GetChildren()
for i, v in pairs(tableofsfx) do -- parenting each specific sound instance to humanoidrootpart
print(i)
print(v)
v.Parent = humanoid
end
player.Chatted:Connect(function(themessage)
local amountofletter = themessage.len(themessage)
if amountofletter < 5 then
print("1")
tableofsfx[math.random(1,15)]:Play() -- it plays from character now!
end
end)
end)
end)