Attempt to index nil with 'character'

Issue : When ran and exited out the the terminal gui it displays an error


Heres the code and the workspace

local player = game:GetService("Players")
local frame = player.LocalPlayer.PlayerGui["Terminal_ V.0.1"].Frame
local playerMod = require(game:GetService("Players").LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local controls = playerMod:GetControls()
local frame2 = player.LocalPlayer.PlayerGui["Terminal_ V.0.1"].Terminal
local Anim = game.StarterGui["Terminal_ V.0.1"]["Open scripts"]["Animation loader"]:WaitForChild("Idle")


script.Parent.MouseButton1Click:Connect(function(plr)
	frame.Visible = false
	frame2.Visible = false
	game.Workspace["terminal V.0.1"].LL.SpotLight.Enabled = false
	game.Workspace["terminal V.0.1"].WORDS.Material = Enum.Material.Marble
	controls:Enable()
	print('tets')
	
	local hum = plr.character:WaitForChild("Humanoid")

	local loadAnim = hum.Animator:LoadAnimation(Anim)

	for _, v in pairs(hum.Animator:GetPlayingAnimationTracks()) do
		if v.Animation.Name == "Idle" then
			v:Stop()
		end
	end
	
end)

image
Any further information needed to help me out here would given out
(I might take a longer time to respond as its late in the night for me as of right now)
Thanks for the help!

character must have a capital C.

1 Like

This should be plr.Character:WaitForChild(“Humanoid”) instead.

1 Like

22:35:07.801 Players.lsand13.PlayerGui.Terminal_ V.0.1.Frame.Exit.Close:17: attempt to index nil with ‘Character’ Nothing much changes

Try something like this:

local plr = game:GetService("Players").LocalPlayer

local hum = plr.Character:WaitForChild("Humanoid")
1 Like


Nothings happens and the animation doesn’t end weird But thanks for the help solving that error moving onto the next bug lmao

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.