Hello! i was trying to make a title system for my game but i noticed a little issue:
For some reason, my friend despite not having the badge for it, has the title
According to him it doesn’t give the title permanently so idk what’s really wrong with my scripts
There were no related errors on both client and server side
I couldn’t reproduce this issue with my alt account
Im using datastore2 to save the title players are using
--Local script that handles the titles
local tween = game:GetService('TweenService')
local badgeService = game:GetService('BadgeService')
local titles = require(game.ReplicatedStorage.Titles)
local event = game:GetService('ReplicatedStorage'):WaitForChild('RemoteEvents').TitleEvent
local plr = game.Players.LocalPlayer
local function createLabel(titleText,titleColor) --Creates a text label for the title
local title = script.Title:Clone()
title.Text = titleText
title.Name = titleText
title.TextColor3 = titleColor
title.Parent = script.Parent.Titles
end
local function setTitle(titleType,id,titleText) --It creates a title
if titleType == 'badge' then
if badgeService:UserHasBadgeAsync(plr.UserId,id) then
createLabel(titleText,titles[titleText])
end
elseif titleType == 'group' then
if plr:GetRankInGroup(9487162) >= 2 then
createLabel(titleText,titles[titleText])
end
elseif titleType == 'other' then
if plr.UserId == 143152820 then
createLabel(titleText,titles[titleText])
end
end
end
setTitle('badge',2124751630,'Engineer')
setTitle('badge',2124951543,'Dreamer')
setTitle('badge',2124813483,'Banisher')
setTitle('badge',2124968492,'Challenger')
setTitle('badge',2125123410,'Rescuer')
setTitle('badge',2125907958,'Researcher')
setTitle('badge',2125907984,'Santa')
setTitle('badge',2127249413,'The Witness')
setTitle('badge',2128130685,'Abyss Researcher')
setTitle('group',0,'Beloved')
setTitle('other',0,'Skill Issue')
for i,v in pairs(script.Parent.Titles:GetChildren()) do
if v:IsA('TextButton') then
v.MouseButton1Click:Connect(function()
workspace.Sounds.ButtonClick:Play()
event:FireServer('EquippedTitle',v.Name,v.TextColor3)
end)
v.MouseEnter:Connect(function()
workspace.Sounds.MouseHover:Play()
tween:Create(v, TweenInfo.new(.5), {BackgroundTransparency = 0.85}):Play()
end)
v.MouseLeave:Connect(function()
tween:Create(v, TweenInfo.new(.5), {BackgroundTransparency = 1}):Play()
end)
end
end
--Server script that handles remote event + datastore
--Keep in mind that its not a full script and im only listing thing's that's related to titles
local function createValue(titleText,parent) --This create string value for the equipped title
local title = Instance.new('StringValue')
title.Name = titleText
title.Value = titleText
title.Parent = parent
end
local function setTitle(plr,titleType,id,titleText,parent) --Creates the title itself
if titleType == 'badge' then
if badgeService:UserHasBadgeAsync(plr.UserId,id) then
createValue(titleText,parent)
end
elseif titleType == 'group' then
if plr:GetRankInGroup(9487162) >= 2 then
createValue(titleText,parent)
end
elseif titleType == 'other' then
if plr.UserId == 143152820 then
createValue(titleText,parent)
end
end
end
game.Players.PlayerAdded:Connect(function(plr)
local playerData = {
['Time'] = dataStore2('Time',plr)
,['Kills'] = dataStore2('Kills',plr)
,['MusicStatus'] = dataStore2('MusicStatus',plr)
,['FOV'] = dataStore2('FOV',plr)
,['Volume'] = dataStore2('Volume',plr)
,['Ragdolls'] = dataStore2('Ragdolls',plr)
,['KillFeed'] = dataStore2('KillFeed',plr)
,['Keybind'] = dataStore2('Keybind',plr)
,['EquippedTitle'] = dataStore2('EquippedTitle',plr)
}
local titlesData = dataStore2('Titles',plr)
setTitle(plr,'badge',2124751630,'Engineer', titles)
setTitle(plr,'badge',2124951543,'Dreamer', titles)
setTitle(plr,'badge',2124813483,'Banisher', titles)
setTitle(plr,'badge',2124968492,'Challenger', titles)
setTitle(plr,'badge',2125123410,'Rescuer', titles)
setTitle(plr,'badge',2125907958,'Researcher', titles)
setTitle(plr,'badge',2125907984,'Santa', titles)
setTitle(plr,'badge',2127249413,'The Witness', titles)
setTitle(plr,'badge',2128130685,'Abyss Researcher', titles)
setTitle(plr,'group',0,'Beloved', titles)
setTitle(plr,'other',0,'Skill Issue', titles)
plr.EquippedTitle.Value = dataStore2('EquippedTitle',plr):Get('None')
game.ReplicatedStorage.RemoteEvents.TitleEvent.OnServerEvent:Connect(function(plrTitle, Status, v, color)
if titlesColor[v] and plrTitle.Titles:FindFirstChild(v) then
if v ~= 'None' then
playerData[Status]:Set(v)
plrTitle.EquippedTitle.Value = v
plrTitle.Character.Head.TitleGui.Title.Text = v
plrTitle.Character.Head.TitleGui.Title.TextColor3 = color
else
playerData[Status]:Set('None')
plrTitle.EquippedTitle.Value = 'None'
plrTitle.Character.Head.TitleGui.Title.Text = ''
end
end
end)
end)
If anyone finds a reason why it happens or if there’s a better way to handle the system please let me know