"Attempt to index nil with clone" Whats wrong? [FIXED!]
Asked by
4 years ago Edited 4 years ago
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)
1 | if purchased and id = = ido then |
2 | plr.Character.Humanoid.WalkSpeed = 20 |
3 | local Backpack = plr.Backpack |
4 | local Devil = ServerStorage:FindFirstChild( "Devil" ):Clone() |
5 | Devil.Parent = Backpack |
end)
game.Players.PlayerAdded:Connect(function(plr)
1 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(plr.UserId,id) then |
2 | game.Workspace:WaitForChild(plr.Name):WaitForChild( "Humanoid" ).WalkSpeed = 20 |
4 | local Devil = ServerStorage:FindFirstChild( "Devil" ):Clone() |
5 | Devil.Parent = Backpack |
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.