How can I attach a sound to a Player on touch?

I have a part that when touched temporarily gives the player super speed.
It also triggers a “speed” sound to support the effect.
However, the sound is playing from the part touched.
I need the sound to emit from the actual player.
Any help here is greatly appreciated.

Here’s what I have currently:

local l = script.Parent
local sound = script.Parent["Sound Effect -- Electrical Shock Sound"]

local l = script.Parent
l.Touched:connect(function(hit)
	local human = hit.Parent:FindFirstChild("Humanoid")
		if human then
			human.WalkSpeed = 150
			sound:Play()
			wait(8)
			human.WalkSpeed = 16
	end
end)

I would say clone the sound into the players character.

3 Likes

Thanks Cyrakohl.
I have no idea how to do that… I’m quite new to scripting.
I’ll see what I can find.

Hope this helps

local l = script.Parent
local sound = script.Parent["Sound Effect -- Electrical Shock Sound"]
local check = false

l.Touched:connect(function(hit)
	if check == false then
		local human = hit.Parent:FindFirstChild("Humanoid")
		if human then
			local Csound = sound:Clone()
			human.WalkSpeed = 150
			Csound.Parent = human.Parent.HumanoidRootPart
			Csound:Play()
			check = true
			wait(8)
			human.WalkSpeed = 16
			Csound:Destroy()
			check = false
		end
	end
end)
1 Like
local Part = script.Parent
local Sound = Part:FindFirstChild("Sound Effect -- Electrical Shock Sound")

Part.Touched:Connect(function(Hit)
	local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
	if Humanoid then
		local NewSound = Sound:Clone() --Clone the sound
		NewSound.Parent = Humanoid.Parent:FindFirstChild("Head") --Parent the sound to character's head
		NewSound:Play() --Play the sound

		Humanoid.WalkSpeed = 150
		wait(8)
		Humanoid.WalkSpeed = 16
	end
end)
1 Like

Thanks PolyAsh!
Works perfectly and saved a lot of time…
I was digging around trying to get the cloning to work, which wasn’t going well :slight_smile:

1 Like

Thanks xSquare!
I didn’t test this but from what little I know, it looks like it would also work!