Button only play sound to user that activated it

I want to have it to where a sound will be activated to only the player that steps on a part.

With all of my scripts it’s either the audio doesn’t play at all or the audio only plays for the server (oddly enough, I have been testing on my phone and pc in the same server and sometimes it has only worked for one or the other) .

I have tried putting local scripts in StarterGUI and StarterPlayer/Character but the audio still plays through the server, I have now just used a remoteEvent, but now the audio isn’t playing at all

here are my current scripts:

ServerScript - serverscriptservice

local sound = game.Workspace.congrations.Sound
local button = game.Workspace.congrations

button.Touched:Connect(function()
		
		game.ReplicatedStorage.RemoteEvent:FireClient()
		
	end)

LocalScript - StarterCharacterScripts

local sound = game.Workspace.congrations.Sound

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
	
	sound:Play()
	
end)

If anybody would like to see how I made the script when it was only local scripts in starter character/player please let me know

1 Like

maybe try parenting the sound to the part. And playing it when the player touches it.

local sound = game.Workspace.congrations.Sound
local button = game.Workspace.congrations

button.Touched:Connect(function(otherpart)
		local player = game.Players:GetPlayerFromCharacter(otherpart.Parent)
if player then
		game.ReplicatedStorage.RemoteEvent:FireClient()
		end
	end)

or try playing it on the server.

local button = game.Workspace.congrations

button.Touched:Connect(function(part)
		local player = game.Players:GetPlayerFromCharacter(otherpart.Parent)
if player then
		game.ReplicatedStorage.RemoteEvent:FireClient(player)
		
	end)

you should do ^^^ in this part below

local sound = game.Workspace.congrations.Sound
local button = game.Workspace.congrations

button.Touched:Connect(function()
		
		game.ReplicatedStorage.RemoteEvent:FireClient()
		
	end)

have you tried printing something in the local script to see if the function ran?

You only fire the thing to one client, not all clients:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.