Skip to content

Conversation

@toxamin
Copy link

@toxamin toxamin commented Nov 17, 2025

No description provided.

@nekofofo369-cyber
Copy link

local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer

local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")

local flyBtn = script.Parent.FlyButton
local upBtn = script.Parent.UpButton
local downBtn = script.Parent.DownButton

local flying = false
local SPEED = 80

local alignOri, alignPos

-- activar / desactivar vuelo
local function toggleFly()
flying = not flying

if flying then
	humanoid:ChangeState(Enum.HumanoidStateType.Physics)

	alignOri = Instance.new("AlignOrientation", root)
	alignOri.MaxTorque = 1e5
	alignOri.Responsiveness = 50
	alignOri.Attachment0 = root.RootAttachment

	alignPos = Instance.new("AlignPosition", root)
	alignPos.MaxForce = 1e5
	alignPos.Responsiveness = 50
	alignPos.Attachment0 = root.RootAttachment
	alignPos.Position = root.Position
else
	if alignOri then alignOri:Destroy() end
	if alignPos then alignPos:Destroy() end
	humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end

end

flyBtn.MouseButton1Click:Connect(toggleFly)

-- móvil ⬆️⬇️
upBtn.MouseButton1Down:Connect(function()
if flying and alignPos then
alignPos.Position += Vector3.new(0, SPEED, 0)
end
end)

downBtn.MouseButton1Down:Connect(function()
if flying and alignPos then
alignPos.Position += Vector3.new(0, -SPEED, 0)
end
end)

-- PC controles
RunService.RenderStepped:Connect(function(dt)
if not flying or not alignPos then return end

local move = Vector3.zero
if UIS:IsKeyDown(Enum.KeyCode.W) then move += root.CFrame.LookVector end
if UIS:IsKeyDown(Enum.KeyCode.S) then move -= root.CFrame.LookVector end
if UIS:IsKeyDown(Enum.KeyCode.A) then move -= root.CFrame.RightVector end
if UIS:IsKeyDown(Enum.KeyCode.D) then move += root.CFrame.RightVector end
if UIS:IsKeyDown(Enum.KeyCode.Space) then move += Vector3.new(0,1,0) end
if UIS:IsKeyDown(Enum.KeyCode.LeftShift) then move -= Vector3.new(0,1,0) end

alignPos.Position += move * SPEED * dt
alignOri.CFrame = workspace.CurrentCamera.CFrame

end)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants