Need help with my sound script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would like to create a button that plays a sound, that all players in the vicinity can hear, as well as plays an animation.

  2. What is the issue? Include screenshots / videos if possible!
    The sound won’t play but the animation will.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I I looked at other topics and tried a remote event (as it worked for someone), no luck. I looked on youtube too, but the one video i found was using a serverscript in a gui (which i thought was unreliable). I’ve tweaked my scripts and tested in studio, nothing.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

EDIT:It works on the client side, i doubt the server side however
There are no errors in the output.
The sound is a child of the head of my model, my remote event is in replicated storage. If you need more/different info please ask.

heres my localscript, it’s located in a gui button:

local button = script.Parent
local Growl = game.ReplicatedStorage.Growl--my remote event


local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid.Animator

local Sound = Character.Head:WaitForChild("Wolf snarl")

local GrowlAnim = Instance.new("Animation")
GrowlAnim.AnimationId = "rbxassetid://6703121332"
GrowlAnim.Parent = script
local GrowlAnimTrack = Animator:LoadAnimation(GrowlAnim)

button.MouseButton1Click:Connect(function()
	GrowlAnimTrack:Play()
	Growl:FireServer(Sound)
	
end)

Heres my Serverscript, its located in startercharacterscripts:


local Growl = game.ReplicatedStorage:WaitForChild("Growl")

Growl.OnServerEvent:Connect(function(Player, Sound)
	Sound:Play()
	print("Sound is playing")
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Parent that script to the ServerScriptService instead, and there are a couple things that I should explain:

  • Anything that’s client sided will only affect your screen; That means animations as well
  • OnServerEvent has a Player parameter that first fired the event, couldn’t you get the Character instead by using that?

Try this:

--Local Side
local button = script.Parent
local Growl = game.ReplicatedStorage.Growl--my remote event

button.MouseButton1Click:Connect(function()
    print("Button fired")
	Growl:FireServer()
end)
--Server Side in ServerScriptService
local Growl = game.ReplicatedStorage:WaitForChild("Growl")

Growl.OnServerEvent:Connect(function(Player)
    print("Event connected")
	local Character = Player.Character
    local Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator")
    local Sound = Character.Head:WaitForChild("Wolf snarl")

    local GrowlAnim = Instance.new("Animation")
    GrowlAnim.AnimationId = "rbxassetid://6703121332"
    GrowlAnim.Parent = Character

    local GrowlAnimTrack = Animator:LoadAnimation(GrowlAnim)
    GrowlAnimTrack:Play()
	Sound:Play()

    print("Animation and Sound playing")
end)

I think it worked (Everything is printing so), Thx!!

1 Like