Billboard gui with adornee not working after player dies/resets

I have billboard guis in the startergui under a folder called “AdorneeUI”.

Each of these billboard guis have an adornee attached to a part in the workspace

https://gyazo.com/220f4fc138cc7870f9ac6efb91ccc14f.png

Then I have a localscript within localplayer scripts that handles the entire pet buying process, here it is:

local plr = game.Players.LocalPlayer
local buyable = false
local db = false
repeat wait() until plr.Character


for i, v in pairs (plr.PlayerGui:WaitForChild('AdorneeUI'):GetDescendants()) do
	if v:IsA("ImageButton") then
		v.MouseButton1Click:Connect(function()
			local numofpets = #game.ReplicatedStorage[plr.Name.."'s Inventory"].Pets:GetChildren()
			if db == false and numofpets < 36 then
			db = true
			local function IsGem()
				if v.Parent.Parent:FindFirstChild("Crystal") then
					return true
				else return false
				end
			end
			if IsGem() == true then
				if game.ReplicatedStorage[plr.Name.."'s Values"].Gems.Value >= v.Parent.Parent.Cost.Value then
					buyable = true
				end
			else
				if game.ReplicatedStorage[plr.Name.."'s Values"].Coins.Value >= v.Parent.Parent.Cost.Value then
					buyable = true
				end
			end
			if buyable == true then
			game.ReplicatedStorage.Remotes.PetBuy:FireServer(v.Item.Text, IsGem(), v.Parent.Parent.Cost.Value)
			buyable = false
			end
			wait(1)
			db = false
			end
		end)
	end
end

The problem here is, once the player resets and they click to buy a pet. It doesn’t do anything

2 Likes

Does it reset the adornee to nil after they die?

If so, you can name each gui uniquely to the player’s name, and use a CharacterLoaded() function to re-attach the adornee to the player.

no it does not reset the adornee to nil, and the adornee is not attached to the character, it is attached to a part that never gets destroyed and is stationary

if it makes any difference, the billboard gui is in the startergui

It may make a difference, you should try putting the billboard gui in the part itself.

i did try that, it didnt work for what i was doing

What I am assuming is that the player is cached, which means that whenever the player dies, the data is old, so to fix this you will need to add a function that updates the player on spawn.

1 Like

and what should be updated when the player respawns?

Whatever associates the player with the BillBoard Gui

That doesn’t work for me as nothing associates the billboard gui with the player

You can disable the ResetOnSpawn property of the BillboardGui to stop this from happening.

I already have that off, still doesn’t fix anything.

Can you maybe send pictures, or a place file, do help us better understand and fix this?

Okay so here it is:

I have billboard guis in the startergui under a folder called “AdorneeUI”.

Each of these billboard guis have an adornee attached to a part in the workspace

https://gyazo.com/220f4fc138cc7870f9ac6efb91ccc14f.png

Then I have a localscript within localplayer scripts that handles the entire pet buying process, here it is:

local plr = game.Players.LocalPlayer
local buyable = false
local db = false
repeat wait() until plr.Character


for i, v in pairs (plr.PlayerGui:WaitForChild('AdorneeUI'):GetDescendants()) do
	if v:IsA("ImageButton") then
		v.MouseButton1Click:Connect(function()
			local numofpets = #game.ReplicatedStorage[plr.Name.."'s Inventory"].Pets:GetChildren()
			if db == false and numofpets < 36 then
			db = true
			local function IsGem()
				if v.Parent.Parent:FindFirstChild("Crystal") then
					return true
				else return false
				end
			end
			if IsGem() == true then
				if game.ReplicatedStorage[plr.Name.."'s Values"].Gems.Value >= v.Parent.Parent.Cost.Value then
					buyable = true
				end
			else
				if game.ReplicatedStorage[plr.Name.."'s Values"].Coins.Value >= v.Parent.Parent.Cost.Value then
					buyable = true
				end
			end
			if buyable == true then
			game.ReplicatedStorage.Remotes.PetBuy:FireServer(v.Item.Text, IsGem(), v.Parent.Parent.Cost.Value)
			buyable = false
			end
			wait(1)
			db = false
			end
		end)
	end
end

The problem here is, once the player resets and they click to buy a pet. It doesn’t do anything

Maybe you missed the part where it checks if the pet was given.

That wouldn’t make sense because if that was the case I wouldn’t be able to buy more than once before i reset.

Your right, maybe try to make it like save as if it was a saving script for coins.

Did you try setting the ResetOnSpawn property in the BillboardGUI’s to false? Just a guess but maybe that’ll fix your problem?

He said he already did a bit up there.

1 Like

That would not work again because when you buy / click on coins for example it does not need to save anything when it resets etc. it just registers the click even when the player has reset. The billboard gui works the same way as the coins therefor not requiring it to be saved

Have you tried a function that makes the pet be there?