I'm trying to make the Roblox Fire Extinguisher compatible with RemoteEvents, The sound works, but nothing else. Local Script
local Tool = script.Parent
local spraying = false
local torso = nil
local offset = 5
local debris = game:GetService("Debris")
local bubble = Instance.new("Part")
bubble.Shape = 0
bubble.formFactor = 0
bubble.Size = Vector3.new(1,1,1)
bubble.Transparency = 0.2
bubble.BottomSurface = "Smooth"
bubble.TopSurface = "Smooth"
bubble.CanCollide = true
function onEquipped(mouse)
mouse.Button1Down:connect(onButton1Down)
mouse.Button1Up:connect(onButton1Up)
game.ReplicatedStorage.BubbleEvent1:FireServer()
end
function onUnequipped()
game.ReplicatedStorage.BubbleEvent2:FireServer()
end
function onButton1Down(mouse)
game.ReplicatedStorage.BubbleEvent3:FireServer()
end
function onButton1Up(mouse)
game.ReplicatedStorage.BubbleEvent4:FireServer()
end
function sprayBubbles()
wait()
game.ReplicatedStorage.BubbleEvent5:FireServer(sprayBubbles)
end
Tool.Equipped:connect(onEquipped)
Tool.Unequipped:connect(onUnequipped)
Server Script
local debounce = false
local timedebounce = 0.1
local spraying = false
local torso = nil
local offset = 5
local debris = game:GetService("Debris")
game.ReplicatedStorage.BubbleEvent1.OnServerEvent:Connect(function(player)
print(player.Character:FindFirstChild("FireExtinguisher"))
torso = player.Character:FindFirstChild("FireExtinguisher").Parent:FindFirstChild("Torso", false) or player.Character:FindFirstChild("FireExtinguisher").Parent:FindFirstChild("UpperTorso", false)
end)
game.ReplicatedStorage.BubbleEvent2.OnServerEvent:Connect(function(player)
spraying = false
player.Character:FindFirstChild("FireExtinguisher").Handle.Mesh.MeshId = "http://www.roblox.com/asset/?id=27787143"
player.Character:FindFirstChild("FireExtinguisher").Handle.FoamSound:Stop()
end)
game.ReplicatedStorage.BubbleEvent3.OnServerEvent:Connect(function(player)
spraying = true
player.Character:FindFirstChild("FireExtinguisher").Handle.Mesh.MeshId = "http://www.roblox.com/asset/?id=27787226"
player.Character:FindFirstChild("FireExtinguisher").Handle.FoamSound:Play()
sprayBubbles()
end)
game.ReplicatedStorage.BubbleEvent4.OnServerEvent:Connect(function(player)
spraying = false
player.Character:FindFirstChild("FireExtinguisher").Handle.Mesh.MeshId = "http://www.roblox.com/asset/?id=27787143"
player.Character:FindFirstChild("FireExtinguisher").Handle.FoamSound:Stop()
end)
game.ReplicatedStorage.BubbleEvent5.OnServerEvent:Connect(function(player)
while spraying do
local sprayDir = torso.CFrame.lookVector.unit
local bubbleClone = bubble:clone()
local torsoNormal = torso.CFrame.lookVector
local denom = math.abs(torsoNormal.x) + math.abs(torsoNormal.z)
local posX = 5 * (torsoNormal.x/denom)
local posZ = 5 * (torsoNormal.z/denom)
bubbleClone.Position = Vector3.new(player.Character:FindFirstChild("FireExtinguisher").Handle.Position.x + posX,player.Character:FindFirstChild("FireExtinguisher").Handle.Position.y,player.Character:FindFirstChild("FireExtinguisher").Handle.Position.z + posZ)
bubbleClone.Velocity = Vector3.new(sprayDir.x,sprayDir.y + 0.5, sprayDir.z) * 50
bubbleClone.Size = Vector3.new(math.random(1,2),math.random(1,2),math.random(1,2))
bubbleClone.Parent = game.Workspace
end
bubbleClone.Touched:Connect(function(h)
for i,v in pairs(h:GetChildren()) do
if v:IsA("ParticleEmitter") then
end
end
wait(0.05)
debris:AddItem(bubbleClone, 2)
end)
end)
script.Parent.OnServerEvent:Connect(function(p,fire)
if p.Name == script.Parent.Parent.Parent.Name then
if fire.Enabled == false or debounce == true then
return
end
print(fire.Parent)
if fire.Rate <= 0 then
fire.Enabled = false
end
fire.Rate = fire.Rate - 2
debounce = true
wait(timedebounce)
debounce = false
end
end)
