I want the character to face right side, here is the script:
local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local cam = workspace.CurrentCamera
local char = player.Character or player.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
cam.CameraType = Enum.CameraType.Scriptable
local speed = 45
local lift = 70
local gravity = -120
local flying = false
local distance = 0
local gui = Instance.new("ScreenGui", player.PlayerGui)
gui.Name = "JetpackGUI"
local label = Instance.new("TextLabel", gui)
label.Size = UDim2.fromScale(0.3,0.08)
label.Position = UDim2.fromScale(0.35,0.03)
label.BackgroundTransparency = 1
label.TextScaled = true
label.TextColor3 = Color3.new(1,1,1)
UIS.InputBegan:Connect(function(i)
if i.UserInputType == Enum.UserInputType.MouseButton1 or i.KeyCode == Enum.KeyCode.Space then
flying = true
end
end)
UIS.InputEnded:Connect(function(i)
if i.UserInputType == Enum.UserInputType.MouseButton1 or i.KeyCode == Enum.KeyCode.Space then
flying = false
end
end)
RunService.RenderStepped:Connect(function(dt)
local vy = hrp.Velocity.Y
if flying then
vy = lift
else
vy += gravity * dt
end
hrp.Velocity = Vector3.new(speed, vy, 0)
hrp.CFrame = CFrame.new(hrp.Position.X, hrp.Position.Y, 0)
cam.CFrame = CFrame.new(
hrp.Position + Vector3.new(20, 10, 40),
hrp.Position + Vector3.new(20, 10, 0)
)
distance += speed * dt
label.Text = math.floor(distance) .. "m"
end)
workspace.World2D.ChildAdded:Connect(function(obj)
if obj.Name == "Coin" then
obj.Touched:Connect(function(hit)
if hit.Parent == char then
obj:Destroy()
end
end)
end
end)
** You are now Level 6! **