My script is supposed to give your character a certain hat if you own a gamepass. There is a hat in serverstorage called cap that you get. I also have a character override script in use if that helps.
gpid = 339516128 hats = {"Cap"} GPS = game:GetService("GamePassService") function respawned(char) char = game.Players:FindFirstChild(char.Name) if char:FindFirstChild("Head") ~= nil then if game:GetService("MarketplaceService"):PlayerOwnsAsset(char,gpid) then for i = 1,#hats do game.ServerStorage:FindFirstChild(hats[i]):Clone().Parent = char end else end end end game.Workspace.ChildAdded:connect(respawned)
gpid = 339516128 hats = {"Cap"} GPS = game:GetService("GamePassService") function respawned(char) local plr = game.Workspace:WaitForChild(char.Name) local HatTag = Instance.new("IntValue") HatTag.Name = "HatTag" HatTag.Parent = char if plr:FindFirstChild("Head") ~= nil then if game:GetService("MarketplaceService"):PlayerOwnsAsset(char,gpid) then for i = 1,#hats do game.ServerStorage:FindFirstChild(hats[i]):Clone().Parent = plr end char.Changed:connect(function(property) Respawn(property, char) end) --Checks to see if this player has died by using ".Changed" else end end end game.Players.PlayerAdded:connect(respawned) function Respawn(property, player) for i = 1,#hats do game.ServerStorage:FindFirstChild(hats[i]):Clone().Parent = player.Character --Puts the hat back on the character. end end
I would also recommend putting the 'Cap' in ReplicatedStorage, as it is the replacement for Lighting, Server Storage is used for other things.