You can access local player functions using
Game.LocalPlayer --- Game is a global variable
You can store player like this
local player = Game.LocalPlayerand then you can access some player data like this
player.OnGroundand you can also set the value like this
player.OnGround = trueand the same with the next fields (some are booleans and others numbers, both you can also set their value)
player.Sneaking
player.Jumping
player.Flying
player.UnderWater
player.CanFly
player.CanConsumeItems
player.MoveSpeed
player.SwimSpeed
player.FlySpeed
player.CurrentHP
player.MaxHP
player.CurrentHunger
player.CurrentLevel = 0.0
player.Gamemode = 0And some others more not listed here By this time player position is still managed the old way, using functions so it would be like this
local x, y, z = player.Position.get()
-- or
player.Position.set(0, 0, 0)You can also access camera info
player.Camera.FOV
player.Camera.Yaw
player.Camera.PitchAnd by last but not less important, you can also access player inventory slots by using
player.Inventory.SlotsSo if you wanna know what item is on slot 1 you need to use
player.Inventory.Slots[1].ItemNameYou could replace 1 by others slots, it accepts 1-36. And also you can directly access the hand/held slot (the current selected slot) using
player.Inventory.Slots["hand"].ItemNameYou can access other item info by replacing ItemName with ItemID, ItemCount or ItemData.
There is another important module called Event that allows you to execute a function when an event is triggered, for example, you can access these events
Game.Event.OnKeyPressed
Game.Event.OnKeyDown
Game.Event.OnKeyReleasedYou can connect functions like this
Game.Event.OnKeyPressed:Connect(function()
--Some code
end)or the other way
Game.Event.OnKeyPressed:Connect(yourFunctionName)So, to allow you to detect what key was pressed, or is down/released, you need the next module called Gamepad. So for the past example to execute code when button A is pressed you do this
Game.Event.OnKeyPressed:Connect(function()
if (Game.Gamepad.isPressed(Game.Gamepad.KeyCodes.A)) then
--Some code
end
end)You can also simplify it a bit by setting local variable Gamepad like this
local Gamepad = Game.Gamepad
Game.Event.OnKeyPressed:Connect(function()
if (Gamepad.isPressed(Gamepad.KeyCodes.A)) then
--Some code
end
end)