Linhas: 59, 66, 77, 84: How can I remove the arrow and put the game default?
Lines: 60, 67, 78, 85 even though I clicking the arrows, wDown = or sDown = -- Does not change to true or false
-- It has no errors on the server, but it does not work.
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
function GetMassRecursive(p)
local mass = 0
for i,v in pairs(p:GetChildren())do
if #v:GetChildren() > 0 then
mass = mass + GetMassRecursive(v)
end
if v:IsA("Part") then
print(v.Name)
mass = mass + v:GetMass()
end
end
return mass
end
local wDown = false
local sDown = false
local isFlying = false
local speed = 10
local s = ""
if Player.PlayerGui:FindFirstChild("TouchGui") then--Check if the Player is mobile
local JumpButton = Player.PlayerGui.TouchGui:WaitForChild("TouchControlFrame"):WaitForChild("JumpButton")
JumpButton.InputBegan:Connect(function(inputobject)
if inputobject.UserInputType == Enum.UserInputType.Touch then
s = s.."w"
delay(0.2,function ()
if s ~= "ww" then
s = ""
end
end)
if s == "ww" then
s = ""
if isFlying then
speed = 0
wait()
Player.Character.UpperTorso["Anti-Grav"]:Destroy()
Player.Character.UpperTorso["FlyingVelocity"]:Destroy()
Player.Character.Humanoid.PlatformStand = false
isFlying = false
else
speed = 10
local f = Instance.new("BodyForce")
f.Name = "Anti-Grav"
f.Force = Vector3.new(0,196.2,0) * (GetMassRecursive(Player.Character))
f.Parent = Player.Character.UpperTorso
local v = Instance.new("BodyVelocity")
v.Velocity = (Mouse.Hit.p - Player.Character.UpperTorso.Position).unit * 10
v.P = 100
v.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
v.Name = "FlyingVelocity"
v.Parent = Player.Character.UpperTorso
Player.Character.Humanoid.PlatformStand = true
isFlying = true
end
end
local Up = Player.PlayerGui.TouchGui:WaitForChild("TouchControlFrame"):WaitForChild("ThumbpadFrame"):WaitForChild("OuterImage"):WaitForChild("UpArrow")
Up.InputBegan:Connect(function(inputobject3)
if inputobject3.UserInputType == Enum.UserInputType.Touch then
wDown = true
end
end)
local Down = Player.PlayerGui.TouchGui:WaitForChild("TouchControlFrame"):WaitForChild("ThumbpadFrame"):WaitForChild("OuterImage"):WaitForChild("DownArrow")
Down.InputBegan:Connect(function(inputobject)
if inputobject.UserInputType == Enum.UserInputType.Touch then
sDown = true
end
end)
end
end)
end
local Up = Player.PlayerGui.TouchGui:WaitForChild("TouchControlFrame"):WaitForChild("ThumbpadFrame"):WaitForChild("OuterImage"):WaitForChild("UpArrow")
Up.InputBegan:Connect(function(inputobject3)
if inputobject3.UserInputType == Enum.UserInputType.Touch then
wDown = false
end
end)
local Down = Player.PlayerGui.TouchGui:WaitForChild("TouchControlFrame"):WaitForChild("ThumbpadFrame"):WaitForChild("OuterImage"):WaitForChild("DownArrow")
Up.InputBegan:Connect(function(inputobject4)
if inputobject4.UserInputType == Enum.UserInputType.Touch then
sDown = false
end
end)
local MAX_SPEED = 500
local MIN_SPEED = 0
spawn(function()
while Player.Character.Humanoid.Health > 0 do
if isFlying then
local r = 1+(speed/500)
Player.Character:SetPrimaryPartCFrame(CFrame.new(Player.Character.PrimaryPart.Position,Mouse.Hit.p)*CFrame.Angles(math.pi/r,math.pi,math.pi))
Player.Character.UpperTorso.FlyingVelocity.Velocity = (Mouse.Hit.p - Player.Character.UpperTorso.Position).unit * speed
if wDown then
speed = speed + 5
if speed > MAX_SPEED then
speed = MAX_SPEED
end
elseif sDown then
speed = speed - 5
if speed < MIN_SPEED then
speed = MIN_SPEED
end
end
end
game:GetService("RunService").RenderStepped:wait()
end
end)
