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 !!!
Unequipped
For thread safety, this property is not safe to read in an unsynchronized thread.
The Unequipped event fires when a player unequips a Tool by putting in back in their Backpack. This event can be used to determine when a player stops using and puts a tool away.
This event does not fire when Tool/RequiresHandle is enabled and no handle is present.
The opposite of this event, Tool/Equipped, can be used alongside this event to determine when a player takes a tool out of their backpack to use.
The example shown below will print “A tool was unequipped” each time the tool is unequipped by the player. Please note that the below example assumes that you’ve already defined what “Tool” is.
Tool.Unequipped:Connect(function()
print("The tool was unequipped")
end)
Code Samples
Player Fly Tool
The code below demonstrates the functionality of several Tool events, including Tool/Activated, Tool/Deactivated, and Tool/Unequipped.
The code, when placed in a LocalScript in the StarterPlayer.StarterCharacterScripts folder inserts and controls a tool in the Players/LocalPlayer|LocalPlayer's Backpack that allows the player to fly through the sky when used.
In order to ensure that the player stops flying when the player unequips the tool, the code uses the tool’s Unequipped event to turn set the fly boolean to true and turn stop flying until the tool is reequipped and activated again.
-- ========================================
-- GLOBAL VARIABLES
-- ========================================
local power = 30
wait()
local tool = nil
local bpos = Instance.new("BodyPosition")
local gyro = Instance.new("BodyGyro")
local fly = false
local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
local char = character:FindFirstChild("UpperTorso")
if not char then char = character:FindFirstChild("Torso") end
local mouse = game.Players.LocalPlayer:GetMouse()
-- ========================================
-- ========================================
-- ========================================
-- SETUP FUNCTION
-- ========================================
-- Create a new tool and place it in the local player's backpack
-- Make this script a child of the tool, script controls flying
local function setupTool()
tool = Instance.new("Tool")
tool.Name = "Fly"
tool.RequiresHandle = false
tool.Parent = game.Players.LocalPlayer.Backpack
gyro.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
bpos.maxForce = Vector3.new(math.huge,math.huge,math.huge)
script.Parent = tool
tool.Parent = game.Players.LocalPlayer.Backpack
end
setupTool()
-- ========================================
-- ========================================
-- ========================================
-- FLY FUNCTIONS
-- ========================================
-- Start flying when player uses tool
function onSelected()
bpos.Parent = char
bpos.position = char.Position + Vector3.new(0,10,0)
gyro.Parent = char
character.Humanoid.PlatformStand = true
for i, v in ipairs(char:GetChildren()) do
if v.className == "Motor" then
v.MaxVelocity = 0
v.CurrentAngle = -1
if v.Name == "Left Hip" then
v.CurrentAngle = 1
end
end
end
fly = true
wait()
while fly do
local pos = mouse.Hit.p
gyro.CFrame = CFrame.new(char.Position,pos) * CFrame.fromEulerAnglesXYZ(-3.14/2,0,0)
bpos.Position = char.Position + (pos-char.Position).unit * power
wait()
end
end
-- Stop flying when player stops using tool
function onDeselected()
gyro.Parent = nil
fly = false
character.Humanoid.PlatformStand = false
for i, v in ipairs(char:GetChildren()) do
if v.className == "Motor" then
v.MaxVelocity = 1
end
end
bpos.Parent = nil
end
tool.Unequipped:Connect(function() fly = false end)
tool.Activated:Connect(onSelected)
tool.Deactivated:Connect(onDeselected)
-- ========================================
-- ========================================
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.