Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't my gampass script work?

Asked by 9 years ago

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.

01gpid = 339516128 
02hats = {"Cap"}
03 
04GPS = game:GetService("GamePassService")
05function respawned(char)
06char = game.Players:FindFirstChild(char.Name)
07if char:FindFirstChild("Head") ~= nil then
08if game:GetService("MarketplaceService"):PlayerOwnsAsset(char,gpid) then
09for i = 1,#hats do
10game.ServerStorage:FindFirstChild(hats[i]):Clone().Parent = char
11end
12else
13end
14end
15end
16game.Workspace.ChildAdded:connect(respawned)

1 answer

Log in to vote
0
Answered by 9 years ago
01gpid = 339516128 
02hats = {"Cap"}
03 
04GPS = game:GetService("GamePassService")
05function respawned(char)
06local plr = game.Workspace:WaitForChild(char.Name)
07local HatTag = Instance.new("IntValue")
08HatTag.Name = "HatTag"
09HatTag.Parent = char
10if plr:FindFirstChild("Head") ~= nil then
11if game:GetService("MarketplaceService"):PlayerOwnsAsset(char,gpid) then
12for i = 1,#hats do
13game.ServerStorage:FindFirstChild(hats[i]):Clone().Parent = plr
14end
15char.Changed:connect(function(property) Respawn(property, char) end) --Checks to see if this player has died by using ".Changed"
View all 26 lines...

I would also recommend putting the 'Cap' in ReplicatedStorage, as it is the replacement for Lighting, Server Storage is used for other things.

0
The script worked, but what I was hoping for was that they get it after respawning too. kelimeguy 60 — 9y
0
If you reset it won't give you it kelimeguy 60 — 9y
0
Edited, it will now do that. Evadable 65 — 9y
0
Now it won't give the hat to he character at all. kelimeguy 60 — 9y
0
nvm it worked! ty! kelimeguy 60 — 9y
Ad

Answer this question