Hello all! I am creating a new RPG game, and I have a level/name tag system. This system, detects the players amount of xp, then removes the previous tag, changes the text of the new tag, clones it, and parents it under the players head.
This seems to fail, after the player dies/respawns, and only clone to "Striker" UI in the ReplicatedStorage If anyone could see why this doesn't function, after a player dies or respawns properly, that'd be greatly appreciated! Thank you!
This is a SERVER SCRIPT in SERVER SCRIPT SERVICE Code:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
if player.leaderstats.xp.Value > 99 then
local gui = game.ServerStorage.peasent:Clone()
gui.TextLabel.Text = (player.Name.."|Peasent")
gui.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
gui.Parent = game.Workspace:WaitForChild(player.Name).Head
end
if player.leaderstats.xp.Value > 149 then
local gui2 = game.ServerStorage.striker:Clone()
char.Head.peasent:Remove()
gui2.TextLabel.Text = (player.Name.."|Striker")
gui2.TextLabel.TextColor3 = Color3.fromRGB(159, 161, 172)
gui2.Parent = game.Workspace:WaitForChild(player.Name).Head
game.Workspace.VillagersQuestBlock1:Destroy()
game.Workspace.villquestblock:Destroy()
end
if player.leaderstats.xp.Value > 249 then
local gui3 = game.ServerStorage.adviser:Clone()
gui3.TextLabel.Text = (player.Name.."|Adviser")
gui3.TextLabel.TextColor3 = Color3.fromRGB(215, 197, 154)
gui3.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.striker:Remove()
end
if player.leaderstats.xp.Value > 399 then
local gui4 = game.ServerStorage.adept:Clone()
gui4.TextLabel.Text = (player.Name.."|Adept")
gui4.TextLabel.TextColor3 = Color3.fromRGB(27, 42, 53)
gui4.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
gui4.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.adviser:Remove()
end
if player.leaderstats.xp.Value > 599 then
local gui5 = game.ServerStorage.ranger:Clone()
gui5.TextLabel.Text = (player.Name.."|Ranger")
gui5.TextLabel.TextColor3 = Color3.fromRGB(75, 151, 75)
gui5.TextLabel.TextStrokeColor3 = Color3.fromRGB(39, 70, 45)
gui5.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.adept:Remove()
game.Workspace.LiadrenQuesTblock:Destroy()
end
if player.leaderstats.xp.Value > 849 then
local gui6 = game.ServerStorage.executer:Clone()
gui6.TextLabel.Text = (player.Name.."|Executer")
gui6.TextLabel.TextColor3 = Color3.fromRGB(61, 63, 75)
gui6.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 0, 0)
gui6.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.ranger:Remove()
game.Workspace.nathenielsquestblock:Destroy()
end
if player.leaderstats.xp.Value > 1199 then
local gui7 = game.ServerStorage.highexecuter:Clone()
gui7.TextLabel.Text = (player.Name.."|High Executer")
gui7.TextLabel.TextColor3 = Color3.fromRGB(27, 42, 53)
gui7.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 0, 0)
gui7.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.executer:Remove()
game.Workspace.BobbiesQuestBlock1:Destroy()
game.Workspace.BobbiesQuestBlock2:Destroy()
end
if player.leaderstats.xp.Value > 1899 then
local gui8 = game.ServerStorage.inquisitor:Clone()
gui8.TextLabel.Text = (player.Name.."|Inquisitor")
gui8.TextLabel.TextColor3 = Color3.fromRGB(4, 175, 236)
gui8.TextLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
gui8.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.highexecuter:Remove()
end
if player.leaderstats.xp.Value > 2049 then
local gui9 = game.ServerStorage.squire:Clone()
gui9.TextLabel.Text = (player.Name.."|Squire")
gui9.TextLabel.TextColor3 = Color3.fromRGB(167, 94, 155)
gui9.TextLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
gui9.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.inquisitor:Remove()
game.Workspace.ParkerQuestblock:Destroy()
end
if player.leaderstats.xp.Value > 2299 then
local gui10 = game.ServerStorage.knight:Clone()
gui10.TextLabel.Text = (player.Name.."|Knight")
gui10.TextLabel.TextColor3 = Color3.fromRGB(245, 205, 48)
gui10.TextLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
gui10.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.squire:Remove()
end
if player.leaderstats.xp.Value > 2749 then
local gui11 = game.ServerStorage.templar:Clone()
gui11.TextLabel.Text = (player.Name.."|Templar")
gui11.TextLabel.TextColor3 = Color3.fromRGB(239, 184, 56)
gui11.TextLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
gui11.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.knight:Remove()
end
if player.leaderstats.xp.Value > 3249 then
local gui12 = game.ServerStorage.director:Clone()
gui12.TextLabel.Text = (player.Name.."|Director")
gui12.TextLabel.TextColor3 = Color3.fromRGB(255, 165, 0)
gui12.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
gui12.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.templar:Remove()
end
if player.leaderstats.xp.Value > 3799 then
local gui13 = game.ServerStorage.marshal:Clone()
gui13.TextLabel.Text = (player.Name.."|Marshal")
gui13.TextLabel.TextColor3 = Color3.fromRGB(159, 173, 192)
gui13.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
gui13.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.director:Remove()
end
if player.leaderstats.xp.Value > 4399 then
local gui14 = game.ServerStorage.baron:Clone()
gui14.TextLabel.Text = (player.Name.."|Baron")
gui14.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
gui14.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
gui14.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.marshal:Remove()
end
if player.leaderstats.xp.Value > 5049 then
local gui15 = game.ServerStorage.warchief:Clone()
gui15.TextLabel.Text = (player.Name.."|Warchief")
gui15.TextLabel.TextColor3 = Color3.fromRGB(86, 36, 36)
gui15.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
gui15.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.baron:Remove()
end
if player.leaderstats.xp.Value > 5649 then
local gui16 = game.ServerStorage.royalknight:Clone()
gui16.TextLabel.Text = (player.Name.."|Royal Knight")
gui16.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
gui16.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
gui16.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.warchief:Remove()
end
if player.leaderstats.xp.Value > 6499 then
local gui17 = game.ServerStorage.nobleman:Clone()
gui17.TextLabel.Text = (player.Name.."|Nobleman")
gui17.TextLabel.TextColor3 = Color3.fromRGB(253, 234, 141)
gui17.TextLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
gui17.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.royalknight:Remove()
game.Workspace.AlexQuestBlock:Destroy()
game.workspace.AlexQuestBlock1:Destroy()
end
if player.leaderstats.xp.Value > 7299 then
local gui18 = game.ServerStorage.kingsguard:Clone()
gui18.TextLabel.Text = (player.Name.."|King's Guard")
gui18.TextLabel.TextColor3 = Color3.fromRGB(0, 32, 96)
gui18.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
gui18.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.nobleman:Remove()
end
if player.leaderstats.xp.Value > 8149 then
local gui19 = game.ServerStorage.warlord:Clone()
gui19.TextLabel.Text = (player.Name.."|Warlord")
gui19.TextLabel.TextColor3 = Color3.fromRGB(170, 0, 170)
gui19.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
gui19.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.kingsguard:Remove()
end
if player.leaderstats.xp.Value > 9049 then
local gui20 = game.ServerStorage.duke:Clone()
gui20.TextLabel.Text = (player.Name.."|Duke")
gui20.TextLabel.TextColor3 = Color3.fromRGB(151, 0, 0)
gui20.TextLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
gui20.Parent = game.Workspace:WaitForChild(player.Name).Head
char.Head.warlord:Remove()
game.Workspace.FreedoQuesTblock:Destroy()
game.Workspace.yardenquestblock:Destroy()
game.Workspace.gloomdaleentry.CanCollide = false
end
end)
end)

1 comment
This doesn't work!