Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does the error say ServerScriptService.Script:28: attempt to index nil with 'Name' ?

Im trying to make a simulator game with a pet shop. Ive never really coded before so i looked up a video for the pet shop. Im doing everything correct but this line wont work. here is the whole line: (first line is the line with error)

if not player.Pets:FindFirstChild(MainPet.Name) then if player.leaderstats[currency].Value >= MainPet.Price.Value then player.leaderstats[currency].Value = player.leaderstats[currency].Value - MainPet.Price.Value local clonedPet = MainPet:Clone() clonedPet.Parent = player.Character clonedPet:SetPrimaryPartCFrame(player.Character.Head.CFrame)

If you know anything about scripting and you may know the issue plz lmk.

2 comments

0

It means you didn't initialize the variable "MainPet", can't say anymore without seeing the whole code

0

In posts like this I think its best to add tutorial you were following.

1 answer

hey you! have you ever heard of enes? if you are in trouble, better call enes!

This discussion is preserved as it was. New answers, comments, and votes are closed.