I'm trying to make a gamepass that gives a player devil powers. I'm getting an error that says "Attempt to index nil with clone"
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
if purchased and id == ido then
plr.Character.Humanoid.WalkSpeed = 20
local Backpack = plr.Backpack
local Devil = ServerStorage:FindFirstChild("Devil"):Clone()
Devil.Parent = Backpack
end
end)
game.Players.PlayerAdded:Connect(function(plr)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then
game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed = 20
local Devil = ServerStorage:FindFirstChild("Devil"):Clone()
Devil.Parent = Backpack
end
end)
EDIT: I fixed it, the problem is that I was using a folder called 'Devil' to hold all of the local scripts inside of it. And folders don't count as objects so when you do something like ":FindFirstChild" with a folder or ":Clone()" with a folder, it breaks because it isn't a thing.

3 comments
Have you initialized ServerStorage as a variable? ServerStorage = game:GetService('ServerStorage'). Also, does Devil really exist in ServerStorage?
Yes
@GameStealerKid I tried that. It did not work, could it be that I'm using FindFirstChild instead of WaitForChild? I did FindFirstChild because WaitForChild was waiting forever (infinte yield possible)