-- Xeno EXQ Superhero Fly Script -- Made for user request local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local rootPart = character:Wait
To enhance the `Superhero Fly Script`, we can make a number of improvements to clarify the messages for the user, improve the performance and structure of the code, and ensure better visual feedback. Below is a revised version of the script that includes these changes:
```lua
-- Xeno EXQ Superhero Fly Script
-- Made for user request
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
-- Fly variables
local flying = false
local speed = 50 -- You can change this value to adjust fly speed
local gravity = workspace.Gravity
-- --- Superhero Animation Setup ---
local animationId = "656118852" -- Common superhero pose
local superheroAnimation = Instance.new("Animation")
superheroAnimation.AnimationId = "rbxassetid://" .. animationId
local animationTrack = humanoid:LoadAnimation(superheroAnimation)
animationTrack.Looped = true
animationTrack.Priority = Enum.AnimationPriority.Action
-- Create BodyVelocity for smooth movement
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.P = 5000
-- Create BodyGyro to control rotation
local bodyGyro = Instance.new("BodyGyro")
bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
bodyGyro.P = 5000
-- Function to toggle flying
local function toggleFly()
flying = not flying
if flying then
bodyVelocity.Parent = rootPart
bodyGyro.Parent = rootPart
humanoid.PlatformStand = true
workspace.Gravity = 0 -- Disable gravity
animationTrack:Play()
print("Flying Enabled. Use WASD to move and Space/Shift to ascend/descend.")
else
bodyVelocity.Parent = nil
bodyGyro.Parent = nil
humanoid.PlatformStand = false
workspace.Gravity = gravity -- Restore original gravity
animationTrack:Stop()
print("Flying Disabled.")
end
end
-- Function to update fly movement
local function updateFly()
if not flying then return end
local moveDirection = Vector3.new(0, 0, 0)
local camera = workspace.CurrentCamera
local lookVector, rightVector = camera.CFrame.LookVector, camera.CFrame.RightVector
-- Check for key presses
if userInputService:IsKeyDown(Enum.KeyCode.W) then
moveDirection = moveDirection + lookVector
end
if userInputService:IsKeyDown(Enum.KeyCode.S) then
moveDirection = moveDirection - lookVector
end
if userInputService:IsKeyDown(Enum.KeyCode.A) then
moveDirection = moveDirection - rightVector
end
if userInputService:IsKeyDown(Enum.KeyCode.D) then
moveDirection = moveDirection + rightVector
end
if userInputService:IsKeyDown(Enum.KeyCode.Space) then
moveDirection = moveDirection + Vector3.new(0, 1, 0)
end
if userInputService:IsKeyDown(Enum.KeyCode.LeftShift) or userInputService:IsKeyDown(Enum.KeyCode.LeftControl) then
moveDirection = moveDirection - Vector3.new(0, 1, 0)
end
-- Apply movement
bodyVelocity.Velocity = moveDirection.Magnitude > 0 and moveDirection.Unit * speed or Vector3.new(0, 0, 0)
-- Update gyro to face the camera direction
bodyGyro.CFrame = CFrame.new(rootPart.Position, rootPart.Position + lookVector)
end
-- Connect input to toggle flying
userInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
-- Press 'E' to toggle fly
if input.KeyCode == Enum.KeyCode.E then
toggleFly()
end
end)
-- Connect the update function to the heartbeat loop for smooth movement
runService.Heartbeat:Connect(updateFly)
-- Notification to the user with improved visibility
local notification = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
local messageLabel = Instance.new("TextLabel", notification)
messageLabel.Text = "Superhero Fly Script Loaded! Press E to toggle flying."
messageLabel.Size = UDim2.new(0, 400, 0, 50)
messageLabel.Position = UDim2.new(0.5, -200, 0, 20)
messageLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
messageLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
messageLabel.TextScaled = true
messageLabel.Visible = true
-- Automatically remove notification after 5 seconds
wait(5)
notification:Destroy()
```
### Key Improvements:
1. **User Feedback**: The notification system has been improved for better visibility and user interaction by using a `TextLabel` in a `ScreenGui`, rather than a message in the workspace.
2. **Code Clarity**: Comments and structure have been maintained for easy readability, and strings have been tweaked for clarity in the printed messages.
3. **Performance Updates**: By directly assigning the `Velocity` of `bodyVelocity` in one line based on its magnitude, we have streamlined the movement function.
4. **User Control Instructions**: Added instructions within the print statement to inform users how to control their movement while flying.
Feel free to customize further according to your preferences!


