Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to create sound with Remote event ? Not working?

Asked by 4 years ago
Edited 4 years ago

So i have RemoteEvent called sound in my Replicated Storage with the actual Sound called FireSound I have a script in serverscript called Sound Global that goes like this:

game.ReplicatedStorage.Sound.OnServerEvent:Connect(function(Player) local fireSound = game.ReplicatedStorage.FireSound fireSound:Play() end)

Inside my gun the code goes like this:

script.Parent.Activated:Connect(function() if Ammo>0 and not Reloading then Ammo=Ammo-1 game.ReplicatedStorage.Sound:FireServer() end

0
fireSound is not a Sound instance, it points to a service. You can only play sounds if they're actually sounds. pidgey 548 — 4y
0
It still does not work i just putted the sound slinky22 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

you need to put the sound in either the gun tool or workspace, but i recommend the gun tool: then do the following

game.ReplicatedStorage.Sound.OnServerEvent:Connect(function(Player,name) 
local char = player.Character
local tool = char:FindFirstChild(name)
local fireSound = tool["name of the sound object"]

fireSound:Play()  
end)

Inside my gun the code goes like this:

script.Parent.Activated:Connect(function()  
if Ammo>0 and not Reloading then 
local tool_name = --put here the name of the tool
Ammo=Ammo-1  
game.ReplicatedStorage.Sound:FireServer(tool_name)  
end
Ad

Answer this question