As the topic says. I’ve been looking around the dev forum for solutions and so far I’ve found absolutely none that work yet. The tool is supposed to grant flight when equipped, but only the server script runs (enables a visual).
The script in question:
local camera = game.Workspace.CurrentCamera
local char = game.Players.LocalPlayer.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local hume = char:WaitForChild("Humanoid")
local animate = char:WaitForChild("Animate")
while (not char.Parent) do char.AncestryChanged:Wait() end
local idleAnim = hume:LoadAnimation(script:WaitForChild("IdleAnim"))
local moveAnim = hume:LoadAnimation(script:WaitForChild("MoveAnim"))
local lastAnim = idleAnim
local bodyGyro = Instance.new("BodyGyro")
bodyGyro.maxTorque = Vector3.new(1, 1, 1)*10^6
bodyGyro.P = 10^6
local bodyVel = Instance.new("BodyVelocity")
bodyVel.maxForce = Vector3.new(1, 1, 1)*10^6
bodyVel.P = 10^4
local isFlying = false
local movement = {forward = 0, backward = 0, right = 0, left = 0}
local function setFlying(flying)
isFlying = flying
bodyGyro.Parent = isFlying and hrp or nil
bodyVel.Parent = isFlying and hrp or nil
bodyGyro.CFrame = hrp.CFrame
bodyVel.Velocity = Vector3.new()
animate.Disabled = isFlying
if isFlying then
lastAnim = idleAnim
lastAnim:Play()
else
lastAnim:Stop()
end
end
local function onUpdate(dt)
if isFlying then
local cf = camera.CFrame
local direction = cf.rightVector* (movement.right - movement.left) + cf.lookVector*(movement.forward - movement.backward)
if direction:Dot(direction) > 0 then
direction = direction.unit
end
bodyGyro.CFrame = cf
bodyVel.Velocity = direction * hume.WalkSpeed * 1.5
end
end
local function movementBind(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
movement[actionName] = 1
elseif inputState == Enum.UserInputState.End then
movement[actionName] = 0
end
if isFlying then
local isMoving = movement.right + movement.left + movement.forward + movement.backward > 0
local nextAnim = isMoving and moveAnim or idleAnim
if nextAnim ~= lastAnim then
lastAnim:Stop()
lastAnim = nextAnim
lastAnim:Play()
end
end
return Enum.ContextActionResult.Pass
end
script.Parent.Equipped:Connect(function()
if char:FindFirstChild("Aura") ~= nil then
setFlying(true)
end
end)
script.Parent.Unequipped:Connect(function()
if char:FindFirstChild("Aura") ~= nil then
setFlying(false)
end
end)
game:GetService("ContextActionService"):BindAction("forward", movementBind, false, Enum.PlayerActions.CharacterForward)
game:GetService("ContextActionService"):BindAction("backward", movementBind, false, Enum.PlayerActions.CharacterBackward)
game:GetService("ContextActionService"):BindAction("left", movementBind, false, Enum.PlayerActions.CharacterLeft)
game:GetService("ContextActionService"):BindAction("right", movementBind, false, Enum.PlayerActions.CharacterRight)
game:GetService("RunService").RenderStepped:Connect(onUpdate)