Equipped (Event)
From Legacy Roblox Wiki
Jump to navigationJump to search
Equipped ( Instance humanoid, Instance skateboardController ) | |
Description | Fired when a skateboard is equipped. |
---|---|
Member of: | SkateboardPlatform |
Description
This event is triggered even a tool is equipped.
In a LocalScript:
Example
local function onEquipped(mouse) mouse.KeyDown:connect(onKeyDown) mouse.Button1Down.connect(function() onButton1Down(mouse) end) end tool.Equipped:connect(onEquipped)
Getting The Mouse Secretly
In one of your games you might want a player to have to click or press a key or something, but what if you don't want them to have to select a hopperbin or tool? One neat thing we can do with the tool is parent it into a player, and the equipped event will fire, giving us their mouse. Then we can do the clicking and pressing stuffs and delete the tool! Here's an example of a script that would get the mouse without them seeing anything:
Example
--This would go in the starterpack. Player = script.Parent.Parent --Get the player. Tool = Instance.new("Tool") --Create a tool. Handle = Instance.new("Part",Tool) --Make a handle part so it will equip. Handle.Name = "Handle" --Make sure it's called handle, or it won't work. Tool.Equipped:connect(function(mouse) --When it's equipped fire a function. Tool.Parent = nil --Delete the tool so they don't see anything. mouse.KeyDown:connect(function(key) --When they press a key fire a function. print(key) --Print the key they pressed. end) --End the key function. end) --End the equip function. Tool.Parent = Player.Character --Parent it to the their character AFTER we have the equipped function ready so it will fire.
Now when the player presses a key it will print, and they didn't have to equip a tool or do anything!
Limitations
- Tool may equip before script add the connection, if both are added to Workspace on another machine.
- This event may not fire if the tool moves or removes before it reaches the right state.