04-10-2011, 05:20 AM
Magic carpet script (put in a tool)
[lua]local carpet=create("Box")
carpet.Name="carpet"
local player=script.Parent.Parent.Parent
carpet.Size=Vec2D(30,2)
carpet.Color=Color(128,0,128)
local fv=create("FixedVelocity")
create("FixedRotation").Parent=carpet
fv.Parent=carpet
local l=create("Label")
l.Parent=carpet
l.Text=player.Name.."'s Magic carpet"
function selected()
if carpet.Parent~=nil then return end
moveto()
carpet.Parent=player.Character
end
function moveto()
carpet.Position=player.Character.Body.Position:add(Vec2D(carpet.Size.x/2,0))
end
function keydown(k)
if k=="r" then
fv.Velocity=Vec2D(0,4-fv.Velocity.y):add(fv.Velocity)
elseif k=="h" then
fv.Velocity=Vec2D(0,0.47-fv.Velocity.y):add(fv.Velocity)
elseif k=="f" then
fv.Velocity=Vec2D(0,0-fv.Velocity.y):add(fv.Velocity)
end
if k=="n" then
moveto()
end
local speed=4
if k=="z" then
fv.Velocity=Vec2D(-speed-fv.Velocity.x,0):add(fv.Velocity)
elseif k=="x" then
fv.Velocity=Vec2D(speed-fv.Velocity.x,0):add(fv.Velocity)
elseif k=="c" then
fv.Velocity=Vec2D(-fv.Velocity.x,0):add(fv.Velocity)
carpet.Velocity=Vec2D(-carpet.Velocity.x,0):add(carpet.Velocity)
else
carpet.Velocity=Vec2D(-carpet.Velocity.x,0):add(carpet.Velocity)
end
end
function keyup(k)
end
link(script.Parent.Selected,selected)
link(script.Parent.KeyDown,keydown)
link(script.Parent.KeyUp,keyup)[/lua]
[lua]local carpet=create("Box")
carpet.Name="carpet"
local player=script.Parent.Parent.Parent
carpet.Size=Vec2D(30,2)
carpet.Color=Color(128,0,128)
local fv=create("FixedVelocity")
create("FixedRotation").Parent=carpet
fv.Parent=carpet
local l=create("Label")
l.Parent=carpet
l.Text=player.Name.."'s Magic carpet"
function selected()
if carpet.Parent~=nil then return end
moveto()
carpet.Parent=player.Character
end
function moveto()
carpet.Position=player.Character.Body.Position:add(Vec2D(carpet.Size.x/2,0))
end
function keydown(k)
if k=="r" then
fv.Velocity=Vec2D(0,4-fv.Velocity.y):add(fv.Velocity)
elseif k=="h" then
fv.Velocity=Vec2D(0,0.47-fv.Velocity.y):add(fv.Velocity)
elseif k=="f" then
fv.Velocity=Vec2D(0,0-fv.Velocity.y):add(fv.Velocity)
end
if k=="n" then
moveto()
end
local speed=4
if k=="z" then
fv.Velocity=Vec2D(-speed-fv.Velocity.x,0):add(fv.Velocity)
elseif k=="x" then
fv.Velocity=Vec2D(speed-fv.Velocity.x,0):add(fv.Velocity)
elseif k=="c" then
fv.Velocity=Vec2D(-fv.Velocity.x,0):add(fv.Velocity)
carpet.Velocity=Vec2D(-carpet.Velocity.x,0):add(carpet.Velocity)
else
carpet.Velocity=Vec2D(-carpet.Velocity.x,0):add(carpet.Velocity)
end
end
function keyup(k)
end
link(script.Parent.Selected,selected)
link(script.Parent.KeyDown,keydown)
link(script.Parent.KeyUp,keyup)[/lua]
Siggy by McNoobster!