Hello developers. I am having an issue with a sound being played when a RemoteEvent fires. In theory it should work, but it is programming so of course it wont. I have tried to make a seperate part in the tool where the sound plays but it won’t be heard in FP.
So far I have made a viewmodel, so the head of the viewmodel could be blocking out sound but I have turned off CanCollide. If any of you know how to fix this, please reply.
Example:
Thanks to anyone who helps. This is my first post on the devforum, so sorry if its in the wrong category or is sloppy.
Wait, I’m confused. Which sound is missing? I can hear the gunshots and shell casings in FP. Also, have you tried turning off the AudioCanCollide property?
I was unaware that there was such thing as AudioCanCollide. Also, even though the gunshots are audible, they are very soft compared to TP. I am trying to find a way to make it clearly audible without turning up the sounds volume and deafening anybody who shoots in TP.
local gun = script.Parent
local shootEvent = gun:WaitForChild("ShootEvent")
local debris = game:GetService("Debris")
shootEvent.OnServerEvent:Connect(function(player, targetPos, gunName)
local character = player.Character
if not character then return end
local gunPart = character:FindFirstChild("ViewModelTPS" .. gunName).rayOrigin
local gunshot = game.ReplicatedStorage.gunshot:Clone()
if not gunPart then return end
local Beam = gunPart.Beam
local att0 = gunPart.Attachment0
local att1 = gunPart.Attachment1
local rayOrigin = gunPart.Position
local rayDirection = (targetPos - rayOrigin).Unit * 1000
local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {character}
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.IgnoreWater = true
local result = workspace:Raycast(rayOrigin, rayDirection, rayParams)
local function BulletTracer(hitPosition)
local ORIGINAlPos = att1.WorldPosition
att1.WorldPosition = hitPosition
gunPart.Beam.Enabled = true
task.delay(0.06, function()
att1.WorldPosition = ORIGINAlPos
gunPart.Beam.Enabled = false
end)
end
if result then
BulletTracer(result.Position)
gunshot.Parent = script.Parent.Handle
gunshot:Play()
else
local missPosition = rayOrigin + rayDirection * 50
BulletTracer(missPosition)
gunshot.Parent = gunPart
gunshot:Play()
end
if result then
local hitPart = result.Instance
local Model = hitPart:FindFirstAncestorOfClass("Model")
if Model then
if Model:FindFirstChild("Humanoid") then
if hitPart.Name == "Head" then
Model.Humanoid.Health -= 50
else
Model.Humanoid.Health -= 30
end
end
end
end
end)
I did not share my script because I don’t think it will make much of a difference since the only sound related part is in the if result then part and the rest is raycasting + damage.