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

My gamepass Donator hat giver won't work?

Asked by
Rdite 30
9 years ago

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)


0
Any error in output? AmericanStripes 610 — 9y
0
Nope. Rdite 30 — 9y
0
OH I FIGURED IT OUT IT NEEDS TO BE CHAR NOT PLAYER TO CLONE INTO! Rdite 30 — 9y
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 Merely 2122 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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.

Ad

Answer this question