Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My gamepass Donator hat giver won't work?

I don't see whats wrong with this the hat is in serverstorage in a folder called DonatorItems and the hat is called Coney.

wait(2)

gpid = 235360162
hats = {"Coney"}

GPS = game:GetService("GamePassService")
function respawned(char)
player = game.Players:FindFirstChild(char.Name)
if char:FindFirstChild("Head") ~= nil then
if GPS:PlayerHasPass(player, gpid) then
for i = 1,#hats do
game.ServerStorage:FindFirstChild(hats[i]):Clone().Parent = player
end
else
end
end
end
game.Workspace.ChildAdded:connect(respawned)


4 comments

0

Any error in output?

0

Nope.

0

OH I FIGURED IT OUT IT NEEDS TO BE CHAR NOT PLAYER TO CLONE INTO!

1

A quick note: GamePassService:PlayerHasPass only updates once per game, so if you buy a game pass in the middle of the game, it will still return false. You should use MarketplaceService:PlayerOwnsAsset instead. http://wiki.roblox.com/index.php?title=API:Class/MarketplaceService/PlayerOwnsAsset

1 answer

✓ Accepted answer

It seems that you might have already had your question answered. However, I'd like to suggest some code changes.

The first one:

wait(2)

I'd assume that you're waiting for something more specific than that, so I'd suggest making it wait for a specific object or condition, rather than just an arbitrary amount, in order to ensure that your script is more robust.

I'd also suggest that you use game.Players:GetPlayerFromCharacter(char), rather than using FindFirstChild to locate the object.

This discussion is preserved as it was. New answers, comments, and votes are closed.