Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a Flamethrower which burns and break joints of models? [closed]

Asked by 9 years ago

So... I want to make a Flamethrower, which burns parts, and breaks the joints of models stuck together, like a mech. And umm, I already got the basis of the flamethrower and the joint breaker, but, I can't seem to apply the joint breaker to the flames that the script makes the fire... Can anyone help me?

switch = script.Parent
on = switch.isOn
bin = switch.Parent
spawn = bin.Pilot
deb = false
switch.BrickColor = BrickColor.new("Bright red")
on.Value = false

while true do
wait(0.1)
if on.Value == true then
p = Instance.new("Part")
p.Name = "Fire"
p.Size = Vector3.new(3,3,3)
p.Shape = "Ball"
p.TopSurface = "Smooth"
p.BottomSurface = "Smooth"
p.Transparency = 0.5
p.Anchored = false
p.CanCollide = false
p.CFrame = spawn.CFrame
script.Move:Clone().Parent = p
---
rand = math.random(1,3)
if rand == 1 then p.BrickColor = BrickColor.new("Bright red")
elseif rand == 2 then p.BrickColor = BrickColor.new("Bright orange")
elseif rand == 3 then p.BrickColor = BrickColor.new("Bright yellow")
end
---
function onTouched(part)
part:BreakJoints()
end
---
script.Parent.Touched:connect(onTouched) -- This is the bit I'm stuck on
---
p.Parent = game.Workspace
end
end


Thanks!

Locked by JesseSong

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 9 years ago

You're best off making a separate script in the script that's disabled, and cloning it to the fire part like you did on line 22 but like this:

local spread = script.FireSpread:Clone() --Clone the script
spread.Parent = p --Parent the script to the Fire part.
spread.Disabled = false --Disabled the spread script.

And in the script called FireSpread, put this code into it:

script.Parent.Touched:connect(function(hit) --Anonymous Touched function, with an argument of hit, which is the part that the script's parent touched.
    if hit.Parent:IsA("Model") then --Not sure if you wanted to break joints of parts in a character or a model, so I just put it as a model. Tell me if you need it for the character instead.
        local f = Instance.new("Fire", hit) --Creates a fire object in the part that was touched.
        --Adjust fire properties here.
        hit:BreakJoints() --Break the touched part's joints.
    end
end)
Ad
Log in to vote
0
Answered by
Tynezz 0
9 years ago
switch = script.Parent
on = switch.isOn
bin = switch.Parent
spawn = bin.Pilot
deb = false
switch.BrickColor = BrickColor.new("Bright red")
on.Value = false

while true do
wait(0.1)
if on.Value == true then
p = Instance.new("Part")
p.Name = "Fire"
p.Size = Vector3.new(3,3,3)
p.Shape = "Ball"
p.TopSurface = "Smooth"
p.BottomSurface = "Smooth"
p.Transparency = 0.5
p.Anchored = false
p.CanCollide = false
p.CFrame = spawn.CFrame
script.Move:Clone().Parent = p
---
rand = math.random(1,3)
if rand == 1 then p.BrickColor = BrickColor.new("Bright red")
elseif rand == 2 then p.BrickColor = BrickColor.new("Bright orange")
elseif rand == 3 then p.BrickColor = BrickColor.new("Bright yellow")
end
---
p.Touched:connect(function(hit)
hit:BreakJoints() end)
---

---
p.Parent = game.Workspace
end
end