I got this bandage that heals 3 times and then destroys itself. The problem is the fact that I can’t seem to make the HUD disappear before the tool destroys, so the HUD stays. I’ve tried making it not visible, transparency to 1, nothing. I don’t know how to proceed, so I need some help.
if it helps this is the code that clones the GUI and puts it into the player’s screen
local gui
local equipped = false
script.Parent.Equipped:Connect(function()
equipped = true
if not game.Players.LocalPlayer.PlayerGui:FindFirstChild("HUD") then -- Gui's name.
script.Parent.HUD.Enabled = true
gui = script.Parent.HUD:Clone() -- Replace with GUI's name.
gui.Parent = game.Players.LocalPlayer.PlayerGui
end
end)
script.Parent.Unequipped:Connect(function()
equipped = false
gui:Destroy()
end)
You’re creating or presenting 2 Guis at the same time. Maybe just clone once and put it in a variable, refer that variable to manipulate its properties.
I can set the visible property with that script, but for the healing script (doubling as the durability script) I doesn’t seem to work. Maybe its the code where I think it tries to detect and find the HUD in the player’s gui?
This is my code for the durability and deleting it, but it doesn’t seem to be doing anything
if Durability == 1 then --- destroy after durability runs out
print("Tool broke")
script.Parent.HUD.Enabled = false
wait(0.5)
script.Parent:Destroy() --- actual destroy self line
end
end
You could try destroying the Gui when you break the tool. If that doesn’t work, you can go to the player’s PlayerGui and find the GUI and delete it from there.
the tool is located inside of my class system inside startergui, so it won’t work. If I add enough .Parent’s, its just the same as game.Players.PlayerGui
well I have to get the PlayerGui, but I don’t know how to make it link to the player, so I looked through it and thought LocalPlayer must be it. I can’t get the PlayerGui if there is nothing in front of Players
you can use localplayer only in a localscript
to fix your problem add this local Player = script.Parent.Parent.Parent
then replace every LocalPlayer with Player