I have a pepperspray system, client fires an event, server receives it and sprays the pepperspray. The client is activated by the player clicking on the pepper spray(as a tool).
So, I want to add audio, one for when the spray is spraying. Which I’m having trouble doing.
I also want to send audio, only for the local player who gets sprayed.(like heavy breathing or something)
Any assistance on how to do this would be appreciated.
Serverscript:
local function verify(plr)
local t = false
if plr.TeamColor == BrickColor.new("Lapis") then
t = "Correctional Officers"
end
if plr.TeamColor == BrickColor.new("Dark blue") then
t = "Team"
end
if not t then return false end
return t
end
game.ReplicatedStorage.PepperEvents.Fire.OnServerEvent:connect(function(plr, s)
if not verify(plr) then return end
if s.Name ~= "Spray" then return end
s.Enabled = not s.Enabled
if s.Enabled then
end
end)
Client:
local tool = script.Parent
local pepperEventsFire = game.ReplicatedStorage.PepperEvents.Fire
tool.Activated:Connect(function()
pepperEventsFire:FireServer(tool.Fire.Spray)
end)
tool.Unequipped:Connect(function()
if tool.Fire.Spray.Enabled then
pepperEventsFire:FireServer(tool.Fire.Spray)
end
end)
Hitbox script(For the player who was hit, this is a serverscript and not local. This just shows a “orange” screen for the GUI effect as being blinded):
script.Parent.Touched:connect(function(hit)
if not script.Parent.Parent.Fire.Spray.Enabled then return end
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.Character.Humanoid.Sit = true
if plr.PlayerGui:FindFirstChild("Peppered") then plr.PlayerGui:FindFirstChild("Peppered"):Destroy() end
game.ReplicatedStorage.PepperEvents.Peppered:Clone().Parent = plr.PlayerGui
end
end)