Type Index Pages
- BillboardGui
- CanvasGroup
- Frame
- Hint
- ImageButton
- ImageLabel
- PlayerGui
- ScreenGui
- ScrollingFrame
- StarterGui
- SurfaceGui
- TextBox
- TextButton
- TextLabel
- UIAspectRatioConstraint
- UIGradient
- UIGridLayout
- UIListLayout
- UIPadding
- UIPageLayout
- UIScale
- UISizeConstraint
- UITableLayout
- UITextSizeConstraint
- VideoFrame
- ViewportFrame
- ChangeHistoryService
- CoreGui
- DataModelSession
- DockWidgetPluginGui
- MultipleDocumentInterfaceInstance
- Plugin
- PluginAction
- PluginGui
- PluginGuiService
- PluginManager
- PluginMenu
- PluginMouse
- PluginToolbar
- PluginToolbarButton
- QWidgetPluginGui
- Selection
- StandalonePluginScripts
- StatsItem
- StudioService
- StudioTheme
No results found!
-
Instance
- GameSettings
- DebugSettings
- BodyMover
- WeldConstraint
- HttpRbxApiService
- NotificationService
- Translator
- Lighting
- Beam
- GuiService
- UserInputService
- Studio
- Plugin
- HttpService
- Mouse
- BindableEvent
- RunService
- Pages
- Humanoid
- TestService
- PathfindingService
- Chat
- NetworkPeer
- Feature
- CharacterAppearance
- Constraint
- NetworkReplicator
- JointInstance
- Light
- BasePlayerGui
- AnalyticsService
- NetworkMarker
- BinaryStringValue
- FlyweightService
- Geometry
- LoginService
- InstancePacketCache
- ThirdPartyUserService
- TouchInputService
- RuntimeScriptService
- GuidRegistryService
- PartOperationAsset
- DialogChoice
- PhysicsService
- AdService
- TextService
- MarketplaceService
- TeleportService
- Accoutrement
- GamePassService
- AssetService
- InsertService
- PointsService
- ChangeHistoryService
- ServerScriptService
- JointsService
- LogService
- InputObject
- Toolbar
- LuaSettings
- RenderSettings
- AnimationTrack
- PhysicsSettings
- NetworkSettings
- CFrameValue
- Animation
- Color3Value
- BoolValue
- BrickColorValue
- Vector3Value
- AnimationController
- BindableFunction
- Button
- Trail
- LocalizationTable
- LocalizationService
- DebuggerBreakpoint
- DebuggerWatch
- ScriptDebugger
- Animator
- Attachment
- RemoteFunction
- RemoteEvent
- PluginManager
- Camera
- Stats
- Sky
- StarterPlayer
- Dragger
- TerrainRegion
- Path
- TextFilterResult
- Dialog
- StatsItem
- GoogleAnalyticsConfiguration
- ScriptContext
- ControllerService
- CacheableContentProvider
- ReflectionMetadataClasses
- ReflectionMetadataEnums
- DebuggerManager
- GuiBase
- UIBase
- LuaSourceContainer
- GuiItem
- DataModelMesh
- ServiceProvider
- ReflectionMetadataItem
- PostEffect
- PhysicsPacketCache
- TouchTransmitter
- RobloxReplicatedStorage
- Visit
- LuaWebService
- ScriptService
- FlagStandService
- VirtualUser
- SpawnerService
- TimerService
- CookiesService
- Team
- GroupService
- StarterGear
- Message
- PlayerScripts
- Configuration
- ContentProvider
- CollectionService
- Debris
- ReplicatedFirst
- ServerStorage
- ReplicatedStorage
- Folder
- TweenService
- Players
- ContextActionService
- StarterPlayerScripts
- SoundService
- KeyframeSequenceProvider
- VRService
- PluginGuiService
- Player
- Teams
- Pose
- Keyframe
- KeyframeSequence
- IntConstrainedValue
- DoubleConstrainedValue
- ForceField
- RayValue
- Fire
- Smoke
- Sparkles
- ParticleEmitter
- IntValue
- StringValue
- NumberValue
- Explosion
- ObjectValue
- SoundGroup
- UserGameSettings
- ClickDetector
- Sound
- Selection
- BadgeService
- TaskScheduler
- GlobalDataStore
- DataStoreService
- CustomEvent
- CustomEventReceiver
- VirtualInputManager
- FunctionalTest
- TweenBase
- SoundEffect
- ReflectionMetadataEvents
- ClusterPacketCache
- PVInstance
- FaceInstance
- Controller
- ReflectionMetadataCallbacks
- ReflectionMetadataFunctions
- ReflectionMetadataYieldFunctions
- ReflectionMetadataProperties
- ReflectionMetadata
- AdvancedDragger
- HapticService
- FriendService
- GamepadService
No Result Found !!!
Velocity
This item is deprecated. Do not use it for new work.
This item is not shown in the object browser. It is likely not intended for widespread use. Expect problems and changes.
The Velocity of a part describes how its /BasePart/Position
is presently changing. The unit of this property is studs per second. For reference, the default Roblox character moves at 16 studs per second via /Humanoid/WalkSpeed
. The acceleration due to gravity is found in /Workspace/Gravity
(by default, -196.2 studs per second).
Setting the Velocity of an part that is /BasePart/Anchored
will cause it to act like a conveyor belt. Any object that touches the part will begin to move in accordance with the Velocity.
Some /BodyMover
objects will apply forces and thus change the Velocity of a part over time. The simplest of these is a /BodyForce
which can be used to counteract the acceleration due to gravity on a single part (set the +Y axis of the /BodyForce/Force
to the product of the mass (/BasePart/GetMass
) and the gravity constant).
Code Samples
Projectile Firing
This code sample fires a part from one position toward another. It calculates the velocity needed to reach the destination in time, and applies an anti-gravity effect using a BodyForce. In addition, it adds a Trail to better visualize the path of the projectile as it arcs through the air.
-- Put this Script in a Part, preferably bullet-shaped :) local part = script.Parent part.Shape = Enum.PartType.Ball part.Size = Vector3.new(2, 2, 2) part.BrickColor = BrickColor.new("Really black") part.CanCollide = false -- Settings for the projectile's path! local startPoint = Vector3.new(0, 50, 0) local targetPoint = Vector3.new(50, 100, 0) local travelTime = 1 local antiGravity = .5 -- Anti-gravity effect: add a BodyForce to counter gravity local bf = Instance.new("BodyForce") bf.Force = Vector3.new(0, workspace.Gravity * part:GetMass() * antiGravity, 0) bf.Parent = part -- Add a trail to two attachments local a0 = Instance.new("Attachment", part) a0.Position = Vector3.new(1, 0, 0) local a1 = Instance.new("Attachment", part) a1.Position = Vector3.new(-1, 0, 0) local trail = Instance.new("Trail", part) trail.Attachment0 = a0 trail.Attachment1 = a1 trail.FaceCamera = true trail.Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(1, 1) }) trail.Lifetime = .35 local function fire(startPoint, targetPoint) -- Calculate how far we have to travel local distance = (targetPoint - startPoint).magnitude -- Since speed = displacement / time, our speed is: local speed = distance / travelTime -- Position our part at the start, pointing to the target part.CFrame = CFrame.new(startPoint, targetPoint) -- Shoot the part part.Velocity = part.CFrame.lookVector * speed end -- Repeatedly fire the projectile while true do fire(startPoint, targetPoint) wait(travelTime) end
How this site use cookies
This Platform uses cookies to offer you a better experience, to personalize content, to provide social media features and to analyse the traffic on our site. For further information, including information on how to prevent or manage the use of cookies on this Platform, please refer to our Privacy and Cookie Policy.