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.
01 | gpid = 339516128 |
02 | hats = { "Cap" } |
03 |
04 | GPS = game:GetService( "GamePassService" ) |
05 | function respawned(char) |
06 | char = game.Players:FindFirstChild(char.Name) |
07 | if char:FindFirstChild( "Head" ) ~ = nil then |
08 | if game:GetService( "MarketplaceService" ):PlayerOwnsAsset(char,gpid) then |
09 | for i = 1 ,#hats do |
10 | game.ServerStorage:FindFirstChild(hats [ i ] ):Clone().Parent = char |
11 | end |
12 | else |
13 | end |
14 | end |
15 | end |
16 | game.Workspace.ChildAdded:connect(respawned) |
01 | gpid = 339516128 |
02 | hats = { "Cap" } |
03 |
04 | GPS = game:GetService( "GamePassService" ) |
05 | function respawned(char) |
06 | local plr = game.Workspace:WaitForChild(char.Name) |
07 | local HatTag = Instance.new( "IntValue" ) |
08 | HatTag.Name = "HatTag" |
09 | HatTag.Parent = char |
10 | if plr:FindFirstChild( "Head" ) ~ = nil then |
11 | if game:GetService( "MarketplaceService" ):PlayerOwnsAsset(char,gpid) then |
12 | for i = 1 ,#hats do |
13 | game.ServerStorage:FindFirstChild(hats [ i ] ):Clone().Parent = plr |
14 | end |
15 | char.Changed:connect( function (property) Respawn(property, char) end ) --Checks to see if this player has died by using ".Changed" |
I would also recommend putting the 'Cap' in ReplicatedStorage, as it is the replacement for Lighting, Server Storage is used for other things.