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

What am I doing wrong with this launch script?

I am attempting to make a script that will launch a rocket using the new explosions and DestroyJointRadiusPercent feature that will fire when I click a button (part button)

print("Launching.")

Main = game.Workspace.Rocket.Head
Remotebomb = script.Parent.Parent
LandMine = script.Parent
Booster = game.Workspace.Rocket.Booster

function onClicked()
	explosion = Instance.new("Explosion")
	explosion.BlastRadius = 50
	explosion.BlastPressure = 1000
	explosion.DestroyJointRadiusPercent = 0
	explosion.Position = Booster.Position --change the "Bomb" to any model name to make that model explode
	explosion.Parent = game.Workspace
	wait(1)
	explosion = Instance.new("Explosion")
	explosion.BlastRadius = 50
	explosion.BlastPressure = 1000
	explosion.DestroyJointRadiusPercent = 0
	explosion.Position = Booster.Position
if
	Main.velocity.y > 10000
	then
	wait(2)
	explosion = Instance.new("Explosion")
	explosion.BlastRadius = 50
	explosion.BlastPressure = 750
	explosion.DestroyJointRadiusPercent = 0
	explosion.Position = Booster.Position
else
	explosion = Instance.new("Explosion")
	explosion.BlastRadius = 50
	explosion.BlastPressure = 5000
	explosion.DestroyJointRadiusPercent = 0
	explosion.Position = Booster.Position
loop(5)
	if Main.velocity.y > 20000
		then
		wait(5)
		explosion = Instance.new("Explosion")
		explosion.BlastRadius = 50
		explosion.BlastPressure = 2500
		explosion.DestroyJointRadiusPercent = 0
		explosion.Position = Booster.Position
	end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

This is what I get out of the Output:

00:34:47.751 - velocity is not a valid member of Part 00:34:47.752 - Script 'Workspace.Model.Explosion trigger.Script', Line 22 00:34:47.753 - Stack End

1 answer

✓ Accepted answer

In lines 22 and 37, the word velocity isn't capitalized. Lua is very case sensitive, so you have to be careful about that. The velocity property in bricks is Velocity. However, the velocity property in a BodyVelocity object is called velocity (No uppercase on the first letter). Hope this helped!

1 comment

1

Thanks for the help! I have the script working, except it freezes my client every time I run it now due to the sheer amount of explosions.

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