Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1° ESTÁVEL -----
- local ProximityPrompt = script.Parent
- local player = game.Players.LocalPlayer
- local Ponte = workspace.Fase1_Ponte.Secao1 -- Suponho que 'Pontee' seja um objeto no 'workspace'
- local Gui = nil -- Vamos armazenar a GUI como variável global
- ProximityPrompt.Triggered:Connect(function(player)
- if player then
- local inHand = player.Character and player.Character:FindFirstChild('Placa de madeira')
- local inBackpack = player.Backpack and player.Backpack:FindFirstChild('Placa de madeira')
- local inHand = player.Character and player.Character:FindFirstChild('Nó 1')
- local inBackpack = player.Backpack and player.Backpack:FindFirstChild('Nó')
- if inHand or inBackpack then
- Ponte.Material = Enum.Material.Wood
- Ponte.BrickColor = BrickColor.new("Rust")
- Ponte.CanCollide = true
- -- Oculta a GUI se ela existir
- if Gui then
- Gui:Destroy()
- Gui = nil
- end
- else
- -- Cria a GUI se ela não existir
- if not Gui then
- Gui = Instance.new("ScreenGui")
- Gui.Parent = player.PlayerGui
- local ImageLabel = Instance.new("ImageLabel")
- ImageLabel.Parent = Gui
- ImageLabel.Size = UDim2.new(0.2, 0, 0.2, 0)
- ImageLabel.Position = UDim2.new(0.417, 0,-0.01, 0)
- ImageLabel.BackgroundTransparency = 1
- ImageLabel.ScaleType = Enum.ScaleType.Crop
- ImageLabel.Image = "rbxassetid://18644825733"
- ImageLabel.Visible = true
- -- Define um timer para ocultar a GUI após 2 segundos
- spawn(function()
- wait(2)
- if Gui and Gui.Parent then
- Gui:Destroy()
- Gui = nil
- end
- end)
- end
- end
- end
- end)
- --------------------
- 2° ESTÁVEL
- local Players = game:GetService("Players")
- local ProximityPrompt = script.Parent
- local Ponte = workspace.Fase1_Ponte.Secao1 -- Suponho que 'Ponte' seja um objeto no 'workspace'
- local Gui = nil -- Vamos armazenar a GUI como variável global
- local player = Players.LocalPlayer
- -- Função para verificar os itens na mochila
- local function checkBackpackItems()
- -- Verifica se o jogador está presente e se ele tem um personagem
- if player and player.Character and player.Character:IsDescendantOf(game.Workspace) then
- -- Verifica se ambos os itens estão na mochila do jogador
- local hasWoodPlankInBackpack = player.Backpack and player.Backpack:FindFirstChild('Placa de madeira')
- local hasKnotInBackpack = player.Backpack and player.Backpack:FindFirstChild('Nó 1')
- print("Placa de madeira na mochila:", hasWoodPlankInBackpack)
- print("Nó 1 na mochila:", hasKnotInBackpack)
- if hasWoodPlankInBackpack and hasKnotInBackpack then
- print("Ambos os itens encontrados na mochila. Alterando a Ponte...")
- -- Ambos os itens estão na mochila, então altera o material da Ponte
- Ponte.Material = Enum.Material.Wood
- Ponte.BrickColor = BrickColor.new("Rust")
- Ponte.CanCollide = true
- -- Oculta a GUI se ela existir
- if Gui then
- Gui:Destroy()
- Gui = nil
- end
- else
- print("Um ou ambos os itens não estão na mochila. Mostrando GUI...")
- -- Cria a GUI se ela não existir
- if not Gui then
- Gui = Instance.new("ScreenGui")
- Gui.Parent = player.PlayerGui
- local ImageLabel = Instance.new("ImageLabel")
- ImageLabel.Parent = Gui
- ImageLabel.Size = UDim2.new(0.2, 0, 0.2, 0)
- ImageLabel.Position = UDim2.new(0.417, 0, -0.01, 0)
- ImageLabel.BackgroundTransparency = 1
- ImageLabel.ScaleType = Enum.ScaleType.Crop
- ImageLabel.Image = "rbxassetid://18644825733"
- ImageLabel.Visible = true
- -- Define um timer para ocultar a GUI após 2 segundos
- spawn(function()
- wait(2)
- if Gui and Gui.Parent then
- Gui:Destroy()
- Gui = nil
- end
- end)
- end
- end
- else
- print("Jogador ou personagem não encontrados. Aguardando...")
- -- Conecta o evento PlayerAdded para garantir que obtemos o jogador corretamente
- local function onPlayerAdded(newPlayer)
- player = newPlayer
- checkBackpackItems()
- end
- Players.PlayerAdded:Connect(onPlayerAdded)
- end
- end
- -- Conectar a função ao evento Triggered do ProximityPrompt
- ProximityPrompt.Triggered:Connect(function()
- print("Triggered! Verificando itens na mochila...")
- checkBackpackItems()
- end)
- -- Verificar os itens na mochila quando o script é iniciado
- checkBackpackItems()
- ------------------
- 3º ESTÁVEL
Advertisement
Add Comment
Please, Sign In to add comment