Attempt to index nil with 'Parent'

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to make a Self-CheckIn System for my Airline, which helps the player to check in and gives them a Boarding Pass.

  2. What is the issue? Include screenshots / videos if possible!
    I have successfuly made and installed it at one of my airports. However, when I place it in my other airport, it gives me this error: ServerScriptService.CheckIn_Handler:10: attempt to index nil with ‘Parent’

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried looking for solutions but haven’t found one.

The system makes use of a remote event.
While the teaming system works, the tool:Clone() function seems to not work after I added it to my other airport.

My script:

local checkin = game.ReplicatedStorage:WaitForChild("Changeteam")

checkin.OnServerEvent:Connect(function(plr, team)
	plr.TeamColor = team
end)

local givetool = game.ReplicatedStorage:WaitForChild("GiveTools")

givetool.OnServerEvent:Connect(function(player, tool)
	tool:Clone().Parent = player.Backpack
end)
1 Like

What happens when you print the tool?
Does the tool exist both client and the server?

Not sure what you mean, this is the output I get when I add print(tool).

 Check in!  -  Server - Script:9
  Economy Class  -  Server - CheckIn_Handler:10
    ServerScriptService.CheckIn_Handler:11: attempt to index nil with 'Parent'  -  Server - CheckIn_Handler:11

Did it print your desired tool. Can you check if it the output is a class type of a tool. Try print(typeof(tool)). Would you mind to show the client script.

This is the output when i do print(typeof(tool))

Instance  -  Server - CheckIn_Handler:10
ServerScriptService.CheckIn_Handler:11: attempt to index nil with 'Parent'

This is the client script:

local team = BrickColor.new("Camo") --Colour of the class
local event = game.ReplicatedStorage:WaitForChild("Changeteam")
local toolevent = game.ReplicatedStorage:WaitForChild("GiveTools")
local frame = script.Parent.Parent
local load = frame.Parent.Loading
local success = frame.Parent.Success
local sound = game.SoundService.Click
local ding = game.SoundService.Success
local tool = game.ReplicatedStorage:WaitForChild("Economy Class")

script.Parent.MouseButton1Click:Connect(function()
	sound:Play()
	frame.Visible = false
	load.Visible = true
	wait(math.random(2,5))
	event:FireServer(team)
	toolevent:FireServer(tool)
	load.Visible = false
	success.Visible = true
	ding:Play()
	wait(2)
	success:TweenPosition(UDim2.new(0.5,0,-1.5,0))
	wait(1)
	for i = 0.4, 1, 0.05 do
		frame.Parent.Blur.BackgroundTransparency = i
		wait(0.1)
	end
	frame.Parent:Destroy()


end)

Not sure why it doesn’t work, but it seems to work perfectly fine here:
https://www.roblox.com/games/6129705884

Do you really need to fire the tool in the client. Why not just clone the tool in the server.

local givetool = game.ReplicatedStorage:WaitForChild(“GiveTools”)
local tool = – directory
givetool.OnServerEvent:Connect(function(player)
tool:Clone().Parent = player.Backpack
end)

I tried it and this is the error:

ServerScriptService.CheckIn_Handler:11: attempt to index nil with 'Parent'  -  Server - CheckIn_Handler:11
1 Like

What’s on line 11?

(too little characters)

This is on line 11, not sure why it doesn’t work in this particular experience. It works fine elsewhere.

https://www.roblox.com/games/6834642526

I’ve tried the script and it worked. I don’t know why it’s not working on you.

Try this:

if tool then
	print("it exists")
else
	warn("bruh moment it doesnt exist bruh burh")
end

This is the output it gave me:

it exists  -  Server - CheckIn_Handler:12
ServerScriptService.CheckIn_Handler:16: attempt to index nil with 'Parent'  -  Server - CheckIn_Handler:16

Still that error idk why

Try this instead:

local cloneTool = tool:Clone()

cloneTool.Parent = player.Backpack
 ServerScriptService.CheckIn_Handler:13: attempt to index nil with 'Parent'  -  Server - CheckIn_Handler:13

hmm

Maybe its some king of bug in roblox studio. Try restarting your roblox studio.

So Roblox says the tool isn’t nil, but somehow cloning it makes it nil? If restarting Roblox Studio doesn’t work, could you show us what “tool” is?

Try this instead:


givetool.OnServerEvent:Connect(function(player, tool)
	local clone = tool:Clone()
clone.Parent = player.Backpack
end)

The tool is a Boarding Pass that shows a gui when equipped.
Screenshot 2022-02-14 at 5.15.23 PM

Not sure why but it still gives me this error.

ServerScriptService.CheckIn_Handler:12: attempt to index nil with 'Parent'  -  Server - CheckIn_Handler:12

Works fine here KVT | Korvatunturi Airport - Roblox
But doesnt work here MER | Mellor Airport - Roblox