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

Attempt to index nil with FindFirstChildWichIsA?

I want to make a custom key to drop tools, and everything works fine on the ClientSide of things and an event is fired, but the actual serversided drop script seems to not work, I can't find why, I tried to make char's "Archivable" value true but it gave a different error, here take a look.

local dropEvent = game.ReplicatedStorage.DropEvent

function onPlayerAdded(plr)
	local char = plr.Character
	
	local function dropItem()
		local tool = char:FindFirstChildWhichIsA("Tool")
		tool.Parent = game.Workspace
	end
	dropEvent.OnServerEvent:Connect(dropItem)
end

game.Players.PlayerAdded:Connect(onPlayerAdded)

The output was: ServerScriptService.Script:7: attempt to index nil with 'FindFirstChildWhichIsA'

Help would be appreciated, thanks.

1 comment

0

I had the same error at one point, the character prob hasn't loaded yet iirc

1 answer

✓ Accepted answer

The character hasn't loaded yet. Fix this with

local char = player.Character or player.CharacterAdded:Wait()

1 comment

0

Thanks dude, helps a lot.

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