hi, i am a beginner developer, and i am making a title shop. however, when you equip a title, it disappears after respawn. i have no idea how to fix this, i tried adding it to the added character but that didnt work. i have no more solutions i can come up with so please help
there is a button on a death screen that activates a title shop gui (i already made most of it work, i just dont know how to make the titles stay on the character after respawn)
local DataStoreService = game:GetService(“DataStore”)
local TitleDataStore = DataStoreService:GetDataStore(“EquippedTitles”)
local function saveTitleOnReset(player)
local character = player.Character
if character then
local equippedTitle = character:FindFirstChild(“TitleBillboard”)
if equippedTitle then
local titleText = equippedTitle.TitleText.Text
TitleDataStore:SetAsync(player.UserId, titleText)
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
– Remove any previous title when the player respawns
local oldTitle = character:FindFirstChild(“TitleBillboard”)
if oldTitle then
oldTitle:Destroy()
end
-- Load the equipped title when the player respawns
local equippedTitle = TitleDataStore:GetAsync(player.UserId)
if equippedTitle then
-- Create a BillboardGui to display the title
local billboardGui = Instance.new("BillboardGui")
billboardGui.Name = "TitleBillboard"
billboardGui.Adornee = character.Head
billboardGui.ExtentsOffset = Vector3.new(0, 1, 0)
billboardGui.Size = UDim2.new(0, 200, 0, 50)
local titleTextObj = Instance.new("TextLabel")
titleTextObj.Name = "TitleText"
titleTextObj
It wont save after joining a new server but should work when you die or reset
i made a new script, but, as expected, the same thing happened. i wonder how i can alter this so that the title remains on the character after respawning?
local titles = game.ReplicatedStorage.Titles
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
if true then
local titleScroll = plr.PlayerGui:WaitForChild("TitlesGui"):WaitForChild("TitlesFrame"):WaitForChild("TitlesScroll")
titleScroll.StarterTitleFrame.EquipButton.MouseButton1Click:Connect(function()
if true then
local leaderstats = plr.leaderstats
if leaderstats.kills.Value > 0 and leaderstats.wins.Value > 0 then
local originalTitle = char:WaitForChild("Head"):FindFirstChildWhichIsA("BillboardGui")
if originalTitle then
originalTitle:Destroy()
end
titles.StarterTitleGui:Clone().Parent = char:WaitForChild("Head")
titleScroll.StarterTitleFrame.EquipButton.Text = "Equipped"
task.wait(3)
titleScroll.StarterTitleFrame.EquipButton.Text = "Equip"
else
plr.PlayerGui.AntiEquipGui.Enabled = true
task.wait(3)
plr.PlayerGui.AntiEquipGui.Enabled = false
end
end
end)
end
end)
end)