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

"Attempt to index nil with clone" Whats wrong? [FIXED!]

Asked by
Desmondo1 121
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)

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.

0
Have you initialized ServerStorage as a variable? ServerStorage = game:GetService('ServerStorage'). Also, does Devil really exist in ServerStorage? ConsteIeo 63 — 4y
0
Yes Desmondo1 121 — 4y
0
@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) Desmondo1 121 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

put devil in replicated storage

Ad

Answer this question