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

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

Asked by 1 year ago

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.

0
It means you didn't initialize the variable "MainPet", can't say anymore without seeing the whole code blowup999 659 — 1y
0
In posts like this I think its best to add tutorial you were following. Sabailuridze 126 — 1y

1 answer

Log in to vote
0
Answered by
enes223 327 Moderation Voter
1 year ago

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

Ad

Answer this question