RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"you will fly when you click a fly button and you control it by where you look"
-- LocalScript inside a ScreenGui with a TextButton named "FlyButton" local flyButton = script.Parent.FlyButton local player = game:GetService("Players").LocalPlayer local character local flying = false local function toggleFly() if character then flying = not flying local humanoid = character:FindFirstChild("Humanoid") if flying then flyButton.Text = "Stop Flying" humanoid.PlatformStand = true else flyButton.Text = "Start Flying" humanoid.PlatformStand = false end end end local function fly() if character and flying then local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") local camera = workspace.CurrentCamera local direction = camera.CFrame.LookVector humanoidRootPart.Velocity = direction * 50 end end flyButton.MouseButton1Click:Connect(toggleFly) game:GetService("RunService").Heartbeat:Connect(fly) player.CharacterAdded:Connect(function(newCharacter) character = newCharacter end) character = player.Character or player.CharacterAdded:Wait()