Learning as i go from my mistakes, go easy on me.
This worked in another project so i copied it to a new one, now i cannot hear the sound outside of studio(Server).
Game is Non-FE and i cannot find the difference/Error between my two projects.
db = false script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if db == false then db = true script.Parent.Transparency = 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1 player.Backpack:WaitForChild('Kaching') player.Backpack.Kaching:Play() wait(math.random(30,60)) script.Parent.Transparency = 0 db = false else end end end)
Hi Yish,
Backpack
. If you want a Sound to be local, as in heard only by one player, then you need to place it into the CurrentCamera
or the Player
itself. However, keep in mind that the CurrentCamera
is client-side only. So, you must use a LocalScript
to access it. Therefore, you need to fire a RemoteEvent from the Server to set off the LocalScript
. Then, this LocalScript will parent the Sound and play it.local players = game:GetService("Players"); local player = players.LocalPlayer; local rs = game:GetService("ReplicatedStorage"); local parent_sound_ev = rs:WaitForChild("Parent Sound"); local cam = workspace.CurrentCamera; function parent_it() local sound = script:WaitForChild("Kaching"):Clone(); local prev_sound = cam:FindFirstChildOfClass("Sound"); if prev_sound then prev_sound:Destroy(); end sound.Parent = cam; sound:Play(); end parent_sound_ev.OnClientEvent:Connect(parent_it);
db = false local rs = game:GetService("ReplicatedStorage"); local play_sound = rs:WaitForChild("Parent Sound") script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if db == false then db = true script.Parent.Transparency = 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1 play_sound:FireClient(player); wait(math.random()) script.Parent.Transparency = 0 db = false else end end end)
Thanks,
Best regards,
~~ KingLoneCat