0% found this document useful (0 votes)
97 views2 pages

Script

This script is designed for a specific player, 'RekzyYT1', in a Roblox game, enabling them to control their character's movement with ascending and descending capabilities. It utilizes services like RunService and UserInputService to manage input and character physics, allowing the player to move in the direction of the camera while adjusting vertical movement based on user inputs. The script binds actions for touch controls and keyboard inputs to facilitate these movements during gameplay.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views2 pages

Script

This script is designed for a specific player, 'RekzyYT1', in a Roblox game, enabling them to control their character's movement with ascending and descending capabilities. It utilizes services like RunService and UserInputService to manage input and character physics, allowing the player to move in the direction of the camera while adjusting vertical movement based on user inputs. The script binds actions for touch controls and keyboard inputs to facilitate these movements during gameplay.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

local player = game.Players.

LocalPlayer
if player.Name ~= "RekzyYT1" then return end
-- aabbaaii if u gona test put ur usser expect RekzyYT1

local RunService = game:GetService("RunService")


local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")

local character = player.Character or player.CharacterAdded:Wait()


local hrp = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera

humanoid.PlatformStand = true

local speed = 60
local ascend = false
local descend = false

local function onTouchAscend(actionName, inputState)


ascend = (inputState == Enum.UserInputState.Begin)
return Enum.ContextActionResult.Sink
end
local function onTouchDescend(actionName, inputState)
descend = (inputState == Enum.UserInputState.Begin)
return Enum.ContextActionResult.Sink
end

if UserInputService.TouchEnabled then
ContextActionService:BindAction("Ascend", onTouchAscend, false, Enum.K-
eyCode.ButtonR2, Enum.KeyCode.ButtonR1)
ContextActionService:BindAction("Descend", onTouchDescend, false,
Enum.KeyCode.ButtonL2, Enum.KeyCode.ButtonL1)
end

UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.Space then
ascend = true
elseif input.KeyCode == Enum.KeyCode.LeftControl then
descend = true
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.Space then
ascend = false
elseif input.KeyCode == Enum.KeyCode.LeftControl then
descend = false
end
end)

RunService.RenderStepped:Connect(function()
local camCFrame = camera.CFrame
local lookVector = camCFrame.LookVector
local moveDir = humanoid.MoveDirection
if moveDir.Magnitude > 0 then
local velocity = lookVector.Unit * speed
if ascend then
velocity = velocity + Vector3.new(0, speed, 0)
elseif descend then
velocity = velocity + Vector3.new(0, -speed, 0)
end
hrp.Velocity = velocity
local camX, camY = camCFrame:ToEulerAnglesXYZ()
hrp.CFrame = CFrame.new(hrp.Position) * CFrame.Angles(0, camY, 0) *
CFrame.Angles(camX, 0, 0)
else
hrp.Velocity = Vector3.new(0, 0, 0)
end
end)

You might also like