When i touch a brick I want to play a sound only for the person who touched the brick, I’ve tried to do it with a local script and a remote event but it wouldn’t work
Hi there, the code could look something like this.
local brick = script.Parent brick.Touched:Connect(function() brick.Sound:Play() end)
this is in a local script. You’ll need to parent the script to this and also the sound you want to play for this to work
put the script inside the brick .
and the local script in playerGui
local RemoteEvent = game.ReplatedStroge:WaitForChild("Event") Script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then RemoteEvent:FireClient(player) end)
RemoteEvent.OnClientEvent:Connect(function(plr) Script.Parent.Sound:Play() end)
The touched event works client side so the remote here is a waste of memory when fired
yes but he want the sound to play on the client side so that’s why i used the event
you cant play the sound on the client with server script its gonna play for everyone
However if touched works in a local script, then theres no need
touched doesn’t work in a local script
i tried this before i made a local script inside the playerGui and used Touch Event to play the sound for the client and the sound played for every one in the game.
(Touch Event doesn’t work will in local script)
try it ur self if u don’t believe me
Can you help me with your script, it doesn’t seem to trigger when i touch the brick
You have to run said script from starterPlayerScripts