RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make me a fly script when I press E I Fly and when I press Q I stop"
-- local script local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local flying = false local function fly() if not flying then flying = true humanoid.PlatformStand = true local bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.Parent = character.HumanoidRootPart bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) bodyVelocity.Velocity = Vector3.new(0, 50, 0) else flying = false humanoid.PlatformStand = false character.HumanoidRootPart.BodyVelocity:Destroy() end end local function onKeyDown(key) if key.KeyCode == Enum.KeyCode.E then fly() elseif key.KeyCode == Enum.KeyCode.Q then if flying then fly() end end end game:GetService("UserInputService").InputBegan:Connect(onKeyDown)