Lua – die besten Beiträge

Roblox Tycoon Upgrade: Wieso wird mein Button nicht angezeigt?

Ich habe in Roblox Studio angefangen, einen Roblox Tycoon zu bauen. Ich habe einen Code, mit dem ich durch Berühren eines Buttons ein Dropper-Upgrade bekomme. Danach sollte eigentlich ein zweiter Button erscheinen, der einen Colorizer erstellt. Dieser Button wird aber nach dem Kauf nicht angezeigt.

Hier der Code:

local tycoon = script.parent.Parent
local mainItems = tycoon:FindFirstChild("MainItems")
local values = tycoon:FindFirstChild("Values")
local buttons = tycoon:FindFirstChild("Buttons")
local purchasedItems = tycoon:FindFirstChild("PurchasedItems")
local objects = {}

mainItems.OwnerDoor.Door.Touched:Connect(function(hit)
  if values.OwnerValue.Value == nil then 
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)

    if player then
      if player:FindFirstChild("HasTycoon").Value == false then
        values.OwnerValue.Value = player
        mainItems.OwnerDoor.Title.SurfaceGui.TextLabel.Text = tostring(values.OwnerValue.Value).."'s Tycoon"
      end
    end
  end
end)

if buttons then
  for i, v in pairs(buttons:GetChildren()) do
    spawn(function()

    if v:FindFirstChild("Button") then
      local newObject = purchasedItems:FindFirstChild(v.Object.Value)

      if newObject ~= nil then
        objects[newObject.Name] = newObject:Clone()
        newObject:Destroy()
      else
        v:Destroy()
      end

      if v:FindFirstChild("Dependency") then
        v.Button.Transparency = 1
        v.Button.CanCollide = false
        v.Button.BillboardGui.Enabled = false
        coroutine.resume(coroutine.create(function()
          if purchasedItems:WaitForChild(v.Dependency.Value) then
            v.Button.Transparency = 0
            v.Button.CanCollide = true
            v.Button.BillboardGui.Enabled = true
          end
        end))
      end

      v.Button.Touched:Connect(function(hit)
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)

        if player then
          if values.OwnerValue.Value == player then
            if v.Button.CanCollide == true then 
              if player:FindFirstChild("leaderstats").Cash.Value >= v.Price.Value then
                player.leaderstats.Cash.Value -= v.Price.Value
                objects[v.Object.Value].Parent = purchasedItems
                v:Destroy()
              end
            end
          end
        end
      end)
    end
  end)
end
end

Ich hoffe, jemand kann mir hier helfen.

Button, Code, lua, Programmiersprache, Roblox, Script, Tycoon, Upgrade, Schaltfläche, Roblox Studio

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