Ive based my script on ROBLOX's extinguishing fire extinguisher gear which worked, but now that I have heavily modified the model I have forgotten which is which. Does anyone know what is wrong with it? Here is my code:
local Tool = script.Parent
local spraying = false
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
SP = script.Parent
FP = game.Workspace.FireAlarmPanel
FP.Status.Changed:connect(function()
if FP.Controller.FiredoorDiscon.Value == true then return end
if FP.Status.Value == 1 or 2 then
sprayBubbles()
if FP.Status.Value == 0 then
print "Sprinkler Armed"
end
end
function sprayBubbles()
local sprayDir = script.Parent.w.CFrame.p.unit
local bubbleClone = bubble:clone()
local torsoNormal = script.Parent.w.CFrame.p
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(Tool.Handle.Position.x + posX,Tool.Handle.Position.y,Tool.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
local script = Tool.ExtinguishScript:clone()
script.Parent = bubbleClone
script.Disabled = false
debris:AddItem(bubbleClone, 2)
wait(0.05)
end
end
Sorry if I am a noob to scripting, I'm not very good at it. Thanks!
~Stewie140
