I was testing/learning this Tycoon Kit made by “Twins” Twin's Tycoon Kit - Roblox . And tried it with a friend. the biggest complaint from my friend was that the sound coming from my purchasing, collecting and etc. can be heard from far away.
So I did some digging and found Sound | Documentation - Roblox Creator Hub. What I did based on this was to add any Sound in the script with .RollOffMinDistance. Example: Sound.RollOffMinFistance(script.Parent.Essentials, Settings.Sounds.Collect)
but then, after running the game, I was not able to collect the money from the collector so couldn’t test the sound… I’m new to this, sorry if the solution is actually basic knowledge
This is the original code I assume the setting for the sound and etc. (untouched version).
deb = false
script.Parent.Essentials.Giver.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
if script.Parent.Owner.Value == player then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.Health > 0 then
if deb == false then
deb = true
script.Parent.Essentials.Giver.BrickColor = BrickColor.new("Bright red")
local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
if Stats ~= nil then
Sound(script.Parent.Essentials, Settings.Sounds.Collect)
Stats.Value = Stats.Value + Money.Value
Money.Value = 0
wait(1)
script.Parent.Essentials.Giver.BrickColor = BrickColor.new("Sea green")
deb = false
end
end
end
end
elseif Stealing.Stealing then -- if player isn't owner and stealing is on
if CanSteal == true then
CanSteal = false
delay(Stealing.PlayerProtection, function()
CanSteal = true
end)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.Health > 0 then
local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
if Stats ~= nil then
local Difference = math.floor(Money.Value * Stealing.StealPrecent)
Sound(script.Parent.Essentials, Settings.Sounds.Collect)
Stats.Value = Stats.Value + Difference
Money.Value = Money.Value - Difference
end
end
end
else
Sound(script.Parent.Essentials, Settings.Sounds.Error)
end
end
end
end)