✓ Accepted answer
Well, I assume that you are waiting for player's character to be added and not for the character.
What's the fix?
Well, there are two ways to fix it. First method, you can use repeat wait() until loop and wait for the player's character to load in :
repeat wait() until player.Character
Second method, you can wait() for the player's character to load in, using CharacterAdded :
player.CharacterAdded:Wait()
Now, some extra information that can be useful what you are trying to do. Here's the sample script, with all the explanation :
local MP = game:GetService('MarketplaceService')
local Players = game:GetService('Players')
local gamepassId = 123456789
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
local char = plr.CharacterAdded:Wait()
local hum = char:WaitForChild('Humanoid')
if MP:UserOwnsGamePassAsync(plr.UserId, gamepassId) then
hum.WalkSpeed = 32
end
MP.PromptGamePassPurchaseFinished:Connect(function(player, passId, Success)
if Success then
if passId == gamepassId then
hum.WalkSpeed = 32
end
end
end)
end)
end)
Lemme know if it helps!
3 comments
thanks a lot!
Add sufficient explanation, don't just write what the user should do. [Look at the other persons answer, and observe]
Its in the code the explanation and where he gone wrong