-
What do you want to achieve? Keep it simple and clear!
Play a sound only to the character that performs the action instead to everyone in the server, but it has to be in a script, not a local script -
What is the issue? Include screenshots / videos if possible!
https://gyazo.com/536e7f234225d066d4a90b614971615d
Rn this is the function that plays the sound, but it’s for everyone -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Everything, from triggering a local script and playing the audio there, etc. It’s for zed’s tycoon audios, so if anyone knows where I can get the PurchaseHandler script fixed or updated I would really appreciate it.
Why can’t you just use a localscript? If it’s for purchases, try using a RemoteEvent and capturing it in client.
RemoteEvent in workspace called PlaySfx
-- Server
function playSfx(player)
workspace.PlaySfx:FireClient(player)
end
-- Client
workspace.PlaySfx.OnClientEvent:Connect(function()
script.Parent.Sound:Play() -- Or whatever
end)
(Just an example)
I already did that with no sucess, mb I’m doing something wrong, but I’m firing client and then OnClientEvent
Can you show us the code of your server/client scripts, with the structure of your workspace as well (Or wherever you are storing the sounds/scripts)?
--[[ All configurations are located in the "Settings" Module script. Plea - Pastebin.com this is the script from zed’s tycoon, lemme try again cuz I removed what I did
No luck, created a remotevent and called it in the function, created a local script that listens that trigger and plays the sound when activated, and called the function playSfx () in the part of the script I wanted it to sound but nope
Where is your sound? Try placing it inside the Head
part, and calling it there from the localscript
I didn’t understand what you’re trying to achieve, can you explain a little more?
Ok, so there are sounds in zeds tycoon when you want to purchase something or collect the money, but they sound global. I want them to sound only for the `person that stepped in that part.
Try placing a local script in StarterGUI or something.
then do this :
local player = game.Players.LocalPlayer
local plrchar = player.Character or player.Character:Wait()
local Debounce = false
local part = game.Workspace.Part -- That part don't need to be in Workspace specifically
local musicsound = game.Workspace.Sound -- Also don't need to be in Workspace
part.Touched:Connect(function(touch)
if touch.Parent == plrchar or touch.Parent.Parent == plrchar and Debounce ~= true then
Debounce = true
musicsound:Play()
Debounce = false
end
end)
Hmmm well, I would have to do that for each team and each part of the tycoon I guess, so that makes it not an alternative sadly :(. I need to get it working from the original script but IDK why Roblox makes it this difficult.
How is the tycoon owner selected in your game?
Is It by just walking on a part?
i don’t think you can fire local script in workspace. They must be in player or character (i didn’t read that correctly so sorry)
I’ll assume that you have a string value somewhere containing the owner’s name and that there are different tycoon owner values and cash parts.
Put a LocalScript in somewhere that only the client can see(StarterGUI or something.)
local plr = game.Players.LocalPlayer
local plrchar = player.Character or plr.CharacterAdded:Wait()
local Debounce = false
local cashpartTycoon1 = game.Workspace.Part -- Can be anywhere.
local cashpartTycoon2 = game.Workspace.Part -- Can be anywhere.
local cashpartTycoon3 = game.Workspace.Part -- Can be anywhere.
local cashpartTycoon4 = game.Workspace.Part -- Can be anywhere.
local cashpartTycoon5 = game.Workspace.Part -- Can be anywhere.
local cashpartTycoon6 = game.Workspace.Part -- Can be anywhere.
local ownerTycoon1 = game.Workspace.StringValue -- Whereever you put It.
local ownerTycoon2 = game.Workspace.StringValue -- Whereever you put It.
local ownerTycoon3 = game.Workspace.StringValue -- Whereever you put It.
local ownerTycoon4 = game.Workspace.StringValue -- Whereever you put It.
local ownerTycoon5 = game.Workspace.StringValue -- Whereever you put It.
local ownerTycoon6 = game.Workspace.StringValue -- Whereever you put It.
local musicsound = game.Workspace.Sound -- Can also be anywhere
cashpartTycoon1.Touched:Connect(function(touch)
if touch.Parent:FindFirstAncestor(plrchar) and Debounce ~= true and plrchar.Name == ownerTycoon1.Value then
Debounce = true
musicsound:Play()
wait()
Debounce = false
end
end)
cashpartTycoon2.Touched:Connect(function(touch)
if touch.Parent:FindFirstAncestor(plrchar) and Debounce ~= true and plrchar.Name == ownerTycoon2.Value then
Debounce = true
musicsound:Play()
wait()
Debounce = false
end
end)
cashpartTycoon3.Touched:Connect(function(touch)
if touch.Parent:FindFirstAncestor(plrchar) and Debounce ~= true and plrchar.Name == ownerTycoon3.Value then
Debounce = true
musicsound:Play()
wait()
Debounce = false
end
end)
cashpartTycoon4.Touched:Connect(function(touch)
if touch.Parent:FindFirstAncestor(plrchar) and Debounce ~= true and plrchar.Name == ownerTycoon4.Value then
Debounce = true
musicsound:Play()
wait()
Debounce = false
end
end)
cashpartTycoon5.Touched:Connect(function(touch)
if touch.Parent:FindFirstAncestor(plrchar) and Debounce ~= true and plrchar.Name == ownerTycoon5.Value then
Debounce = true
musicsound:Play()
wait()
Debounce = false
end
end)
cashpartTycoon6.Touched:Connect(function(touch)
if touch.Parent:FindFirstAncestor(plrchar) and Debounce ~= true and plrchar.Name == ownerTycoon6.Value then
Debounce = true
musicsound:Play()
wait()
Debounce = false
end
end)
I hope It helped.
yeah I mean, the thing is that there are tons of parts so I guess that is difficult :(. I guess my only option is to disable the sounds
The only thing you can do is use a remote event to fire the client. If that doesn’t work, you can also try using SoundService:PlayLocalSound in the remote and see if it changes anything
Try putting the sound in the PlayerGui and make sure you set the volume to a reasonable level.
I already tried the first thing and the problem is that when I change that it bugs and stops playing the sound… is it possible to play a sound within the area of the part? since there is a variable for the part as I see…
I tried literally everything with FireClient:
Script:
https://gyazo.com/539adf1f26cab2cabdccc576570f2dba
Location of remote event and local script:
https://gyazo.com/b503a168a97f09ba0c7ea80633df078a
local script:
https://gyazo.com/9751f5431d05498d4d448873e169ace5
Mb that is more useful to tell me what am I doing wrong? the remote event is fired in the script when a player touches the part.