Serverplayerscripts resetting on death?

Hello! I’ve been working on a VIP gamepass where I want the players to have a billboard GUI above their name and give them a lot of jump. I’ve achieved this properly, but I’ve ran into a problem. The jump power and the name tag goes away when the player dies. How would I fix this?

Here is my current script

Blockquote
local billboardgui = game:GetService(“ServerStorage”):WaitForChild(“BillboardGui”)
local id = [myid]
game:GetService(“MarketplaceService”).PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
if purchased and ido == id then
while true do
plr.Character.Humanoid.WalkSpeed = 25
wait(0.01)
end
end
end)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:connect(function(char)
if game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
char.Humanoid.NameDisplayDistance = 60
local clonedgui = billboardgui:Clone()
clonedgui.Parent = game.Workspace[player.Name].Head
clonedgui.TextLabel.Text = “VIP”
clonedgui.TextVip.Text = player.Name

		while true do
		char.Humanoid.JumpPower = 60
		wait()
		end
		
    end
end)

end)

Blockquote

Serverplayerscripts…? What’s that?

First things first, you should be caching (storing it in a table) the result from UserOwnsGamePassAsync so you don’t have to spam it every time they respawn (you’ll run out of requests if you do this). UserOwnsGamePassAsync should be wrapped in pcall since it performs a request and it can error which is outside of your control. In addition, there is no need to write game.Workspace[player.Name].Head since char points directly to their new character and it can be rewritten as char.Head. You don’t need a while loop to set their JumpPower constantly since you can do it inside of your event listener just as you do with the nametag.

1 Like

I meant server script service… sorry