Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

problems scripting a fly?

ok so i make a Marvel game and for Human Torch from the Fantastic 4 i wanted a "Fire Fly" it works perfectly except for the fact that when i stop flying i die. this is very disappointing cause i have tried to fix it several times and i just cant. this is the clip of script that i have that i made to the original fly i have to make the fire bellow...

function Fly()
	
	if Flying and Player and Torso and Humanoid and Humanoid.Health > 0 then
		
		local Momentum = Vector3.new(0, 0, 0)
		local LastMomentum = Vector3.new(0, 0, 0)
		local LastTilt = 0
		local CurrentSpeed = Speed.MaxSpeed
		local Inertia = (1 - (Speed.CurrentSpeed / CurrentSpeed))
		fire=Instance.new("Fire")
		fire.Heat=0
		fire.Size=10
		fire.Parent=script.Parent.Parent["Left Leg"]
		fire2=Instance.new("Fire")
		fire2.Heat=0
		fire2.Size=10
		fire2.Parent=script.Parent.Parent["Right Leg"]
		fire3=Instance.new("Fire")
		fire3.Heat=0
		fire3.Size=10
		fire3.Parent=script.Parent.Parent["Left Arm"]
		fire4=Instance.new("Fire")
		fire4.Heat=0
		fire4.Size=10
		fire4.Parent=script.Parent.Parent["Right Arm"]
		fire5=Instance.new("Fire")
		fire5.Heat=0
		fire5.Size=10
		fire5.Parent=script.Parent.Parent.Torso
		fire6=Instance.new("Fire")
		fire6.Heat=0
		fire6.Size=10
		fire6.Parent=script.Parent.Parent.Head
		BodyVelocity.maxForce = Vector3.new(1, 1, 1) * (10 ^ 6)	
		
		BodyGyro.maxTorque = Vector3.new(BodyGyro.P, BodyGyro.P, BodyGyro.P)
		BodyGyro.cframe = Torso.CFrame
		
		while Flying and Torso and Humanoid and Humanoid.Health > 0 do
			
			if CurrentSpeed ~= Speed.MaxSpeed then
				CurrentSpeed = Speed.MaxSpeed
				Inertia = (1 - (Speed.CurrentSpeed / CurrentSpeed))
			end
			
			local Direction = CurrentCamera.CoordinateFrame:vectorToWorldSpace(Vector3.new(Controls.Left.Number + Controls.Right.Number, math.abs(Controls.Forward.Number) * 0.2, Controls.Forward.Number + Controls.Backward.Number))
			local Movement = Direction * Speed.CurrentSpeed
			
			Momentum = (Momentum * Inertia) + Movement
			
			local TotalMomentum = Momentum.magnitude
			
			if TotalMomentum > CurrentSpeed then
				TotalMomentum = CurrentSpeed
			end
			
			local Tilt = ((Momentum * Vector3.new(1, 0, 1)).unit:Cross(((LastMomentum * Vector3.new(1, 0, 1)).unit))).y
			local StringTilt = tostring(Tilt)
			
			if StringTilt == "-1.#IND" or StringTilt == "1.#IND" or Tilt == math.huge or Tilt == -math.huge or StringTilt == tostring(0 / 0) then
				Tilt = 0
			end
			
			local AbsoluteTilt = math.abs(Tilt)
			
			if AbsoluteTilt > 0.06 or AbsoluteTilt < 0.0001 then
				if math.abs(LastTilt) > 0.0001 then
					Tilt = (LastTilt * 0.9)
				else
					Tilt = 0
				end
			else
				Tilt = ((LastTilt * 0.77) + (Tilt * 0.25))
			end
			
			LastTilt = Tilt

			if TotalMomentum < 0.5 then
				Momentum = Vector3.new(0, 0, 0)
				TotalMomentum = 0
				BodyGyro.cframe = CurrentCamera.CoordinateFrame
			else
				BodyGyro.cframe = CFrame.new(Vector3.new(0, 0, 0), Momentum) * CFrame.Angles(0, 0, (Tilt * -20)) * CFrame.Angles((math.pi * -0.5 * (TotalMomentum / CurrentSpeed)), 0, 0)
			end
			
			BodyVelocity.velocity = Momentum
			LastMomentum = Momentum
			Wait(FlyRate)
			
		end
		
		BodyVelocity.maxForce = Vector3.new(0, 0, 0)
		BodyPosition.maxForce = Vector3.new(0, 0, 0)
		BodyGyro.maxTorque = Vector3.new(0, 0, 0)
		
	end
end

function StopFlying()
	Flying = false
	BodyVelocity.maxForce = Vector3.new(0, 0, 0)
	BodyPosition.maxForce = Vector3.new(0, 0, 0)
	BodyGyro.maxTorque = Vector3.new(0, 0, 0)
	script.Parent.Parent["Left Leg"]:ClearAllChildren()
	script.Parent.Parent["Right Leg"]:ClearAllChildren()
	script.Parent.Parent["Left Arm"]:ClearAllChildren()
	script.Parent.Parent["Right Arm"]:ClearAllChildren()
	script.Parent.Parent.Torso:ClearAllChildren()
	script.Parent.Parent.Head:ClearAllChildren()
end

ive also tried making the fire greenish for my Dr. Strange but i dont know how to change the color!! D:

if you have time can you also tell me how to use this with particles ... cause i cant figure it out trying to use my own decals ... i just get the classic particle decal.

thank you for reading this and thank you for any help i may receive

~FinickOdre123

1 comment

0

Did you write this all from scratch?

1 answer

You die when you stop flying because of this line:

script.Parent.Parent.Torso:ClearAllChildren()
-- Humanoid is inside the torso!
-- Deleting the Humanoid kills the Player!

Here is the wiki page to the class Fire.

Two properties of fire you can modify are Color and SecondaryColor.

Here's an example in case you are unfamiliar with editing Color3's:

local fire1 = Instance.new("Fire", script.Parent.Torso)
fire1.Size = 10
fire1.Color = Color3.new(0 / 255, 102 / 255, 0 / 255)

Edit If you need to clear the children of Torso without deleting the Humanoid, you can make your own custom ClearAllChildren() function (kind of)

ClearAllChildren() is equivalent to something like this:

for _, v in pairs(object:GetChildren()) do
	v:Destroy()
end

So, to ClearAllChildren() except Humanoid, add a conditional:

for _, v in pairs(script.Parent.Parent.Torso:GetChildren()) do
	if v.ClassName ~= "Humanoid" then
		v:Destroy()
	end
end

2 comments

0

ok so i tried this fire coloration and it made the fire green but i couldn't fly ... also if it isn't ClearAllChildren what would i put???

0

Updated.

This discussion is preserved as it was. New answers, comments, and votes are closed.