This is a hover brick script I made for general use. Hopefully It will be used in the hover-tanks project. The script can make just about any hover-brick just by changing a few values. The script also dos dome basic checks in case the user uses it wrong. To use simply paste into a brick and set the options to what you want.
- Code:
--~~~~~~~~~~~~~~~~~~~~User settable variables~~~~~~~~~~~~~~~~~~~~--
local FORCE = 10000 -- the amount of force this brick will apply to
local SPEC_POS = false -- set to true to specify a specific high for the brick to float at. Otherwise it floats at it's current hight.
local HIGHT = 0 -- How high the brick should float if SPEC_POS it true
local TOGGLE = false -- If true the brick will be a click enabled hover brick
local CLICK_DISTANCE = 32 -- How far away the hover brick can be turned on/off if TOGGLE is true
local DEFUALT_SET = false --determines what state the brick starts out in if TOGGLE is true. false = off and true = on
--~~~~~~~~~~~~~~~~~~~Do not touch below this line~~~~~~~~~~~~~~~~~~~--
this = script.Parent
local toggle = false
function clicked()
if toggle == true then
bodyp.maxForce = Vector3.new(0,0,0)
this.Transparency = 0.50
toggle = false
else
bodyp.maxForce = Vector3.new(0,FORCE,0)
this.Transparency = 0
toggle = true
end
end
function exe()
bodyp = Instance.new("BodyPosition")
bodyp.maxForce = Vector3.new(0,FORCE,0)
-------------------------------------------
if SPEC_POS == true then -- handle specpos setting
bodyp.position = Vector3.new(0,HIGHT,0)
bodyp.Parent = this
else
bodyp.position = this.Position
bodyp.Parent = this
end
--------------------------------------------
if TOGGLE == true then --handle toggle settings
cd = Instance.new("ClickDetector")
cd.Parent = this
cd.MaxActivationDistance = CLICK_DISTANCE
cd.MouseClick:connect(clicked)
if DEFUALT_SET == true then
clicked()
else
clicked()
clicked()
end
end
---------------------------------------------
end
if this.className == "Part" then --If the script is not a child of a Part then warn the user of the problem
if this.Anchored == true then --If the brick is anchored then warn the user
print("Warning: This brick is anchored, the brick will still Hover if you unanchore it but my send objects flying while it's anchored")
end
exe()
else
print("Error: This script's parent is not a valid \"Part\" object. Please insert into a object with the className of \"Part\" (aka a brick).")
end
--~~~~~~~~~~~~~~~~~~~~Created by V1buzzbomb~~~~~~~~~~~~~~~~~~~~--
Thu Apr 08, 2010 3:18 pm by Wako98
» X-101 Enemies
Thu Dec 31, 2009 1:48 pm by TrickyMaster11
» Hello! I'm new.
Thu Dec 31, 2009 1:39 pm by TrickyMaster11
» Groups: WHAT THEY ARE
Sun Dec 13, 2009 1:06 pm by Xtreme101
» Hi I am New.
Thu Nov 05, 2009 9:20 pm by Robo6420
» Notice: Please Use your ROBLOX account.
Thu Nov 05, 2009 9:19 pm by Robo6420
» Noob resistant Hover brick script
Thu Oct 08, 2009 6:29 pm by Robo6420
» Invitation Poll
Thu Oct 08, 2009 4:47 pm by Robo6420
» My First Video
Thu Oct 08, 2009 4:42 pm by Robo6420