Lua – die besten Beiträge

Wie kann ich dieses Skript für Controller und Handy machen?

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local UserInputService = game:GetService("UserInputService")
local Stamina = 100
local Running = false
local SprintSpeed = 30
local WalkSpeed = 16

script.Parent.PlayerName.Text = Player.Name
script.Parent.PlayerThumb.Image = "rbxthumb://type=AvatarHeadShot&id=" ..Player.UserId.. "&w=420&h=420"
Character:WaitForChild("Humanoid"):GetPropertyChangedSignal("Health"):connect(function()
  script.Parent.HealthBar.Bar.Size = UDim2.new(math.floor(Character.Humanoid.Health) / 100, 0, 1, 0)
end)
UserInputService.InputBegan:Connect(function(key)
  if key.KeyCode == Enum.KeyCode.LeftShift then
    Running = true
    Character.Humanoid.WalkSpeed = SprintSpeed

    while Stamina > 0 and Running do
      Stamina -= 1
      --print(Stamina)

      if Stamina == 0 then
        script.Parent.StaminaBar.Bar.Visible = false
      else
        script.Parent.StaminaBar.Bar:TweenSize(UDim2.new(Stamina / 100, 0, 1, 0), "Out", "Linear", 0)
      end

      wait()

      if Stamina == 0 then
        Character.Humanoid.WalkSpeed = WalkSpeed
      end
    end
  end
end)
UserInputService.InputEnded:Connect(function(key)
  if key.KeyCode == Enum.KeyCode.LeftShift then
    Running = false
    Character.Humanoid.WalkSpeed = WalkSpeed

    while Stamina < 100 and not Running do
      script.Parent.StaminaBar.Bar.Visible = true
      Stamina += 1
      --print(Stamina)
      script.Parent.StaminaBar.Bar:TweenSize(UDim2.new(Stamina / 100, 0, 1, 0), "Out", "Linear", 0)
      wait()

      if Stamina == 0 then
        Character.Humanoid.WalkSpeed = WalkSpeed
      end
    end
  end
end)

Ich will, dass man auf Controller RB/R1 drückt und auf Handy soll es eine Taste auf dem Bildschirm (GUI) geben.

Es ist übrigens in Roblox Studio mit Lua geschrieben.

lua, Programmiersprache

Meistgelesene Beiträge zum Thema Lua