Problem I'm trying to make it when the player clicks, a sound plays and an object is thrown. For some reason, the object is throwing but the sound will not play.
Code:
local sp=script.Parent cooldown=.5 debris=game:GetService("Debris") check=true function waitfor(parent,name) while true do local child=parent:FindFirstChild(name) if child~=nil then return child end wait() end end local handle=waitfor(sp,"Handle") function onButton1Down(mouse) if check then check=false local h=sp.Parent:FindFirstChild("Humanoid") local t=sp.Parent:FindFirstChild("Torso") local anim=sp:FindFirstChild("RightSlash") if anim and t and h then local theanim=h:LoadAnimation(anim) theanim:Play(nil,nil,1.5) if theanim and h.Health>0 then wait(.25) handle.Transparency=1 local p=handle:clone() p.Name="Effect" p.CanCollide=false p.Transparency=0 p:findFirstChild("Sanic"):findFirstChild("Image").Visible = true local sound=p:FindFirstChild("SanicSound") if sound then sound:Play() end p.RotVelocity=Vector3.new(0,0,0) p.Velocity=(mouse.Hit.p-p.Position).unit*100+Vector3.new(0,10,0) p.CFrame=CFrame.new(handle.Position,mouse.Hit.p)*CFrame.Angles(-math.pi/2,0,0) debris:AddItem(p,20+math.random()*5) p.Parent=game.Workspace end end wait(cooldown-.25) handle.Transparency=1 check=true end end sp.Equipped:connect(function(mouse) equipped=true mouse.Button1Down:connect(function() onButton1Down(mouse) end) end) sp.Unequipped:connect(function() equipped=false handle.Transparency=1 end)
I'm trying to make the sound 3D so that it gets quieter the farther it gets form the player.