So my sound isnt serversided in my game, I want other people to hear the sound when using the tool but it doesnt work...
local swinganimationid = 9671188351 repeat wait() until game.Players.LocalPlayer.Character local lp = game.Players.LocalPlayer local sp = script.Parent local debounce = true local sound = script.Parent.Sound1 local sound2 = script.Parent.Sound2 local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://" .. swinganimationid local swingtrack = lp.Character.Humanoid:LoadAnimation(anim) sp.Activated:connect(function() if debounce == true then debounce = false swingtrack:Play() sound:Play() sound2:Play() wait(swingtrack.Length) sound2:Stop() sound:Stop() debounce = true end end)
Add a Script, a LocalScript, and a RemoteEvent in your tool. Inside the LocalScript, make the tool.Activated
function:
local swinganimationid = 9671188351 repeat wait() until game.Players.LocalPlayer.Character local lp = game.Players.LocalPlayer local sp = script.Parent local debounce = true sp.Activated:connect(function() if debounce == true then debounce = false script.Parent.RemoteEvent:FireServer(swinganimationid) debounce = true end end)
Then inside the Script, make the animation and the sound play:
local RemoteEvent = script.Parent.RemoteEvent RemoteEvent.OnServerEvent:Connect(function(plr, animId) local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://" .. animId local swingtrack = plr.Character.Humanoid:LoadAnimation(anim) swingtrack:Play() script.Parent.Sound1:Play() script.Parent.Sound2:Play() wait(swingtrack.Length) script.Parent.Sound2:Stop() script.Parent.Sound1:Stop() end)
Hope it helps! Let me know if there are errors and mistakes. ^^