Workspace.Map.GlitchPart.Script:9: attempt to index nil with 'Parent' - Server - Script:9

Hello! So I made a script where if you go in a part a frame shows up while your in the part. Though I been having errors. Is there any way to fix it?
error

Workspace.Map.GlitchPart.Script:9: attempt to index nil with 'Parent'  -  Server - Script:9
script.Parent.Touched:Connect(function(hit)
	local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	local Glitch = Player.PlayerGui:WaitForChild("GlitchEffect")
	Glitch.ImageLabel.Visible = not Glitch.ImageLabel.Visible
end)

script.Parent.TouchEnded:Connect(function(hit, partB)
	local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	local Glitch = Player.PlayerGui:WaitForChild("GlitchEffect")
	Glitch.ImageLabel.Visible = not Glitch.ImageLabel.Visible
	local humanoid = partB.Parent:FindFirstChild("Humanoid")
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(partB.Parent)
		game.ReplicatedStorage.Voiceline:FireClient(player)
	end
end)

The error means that you’re essentially doing nil.Parent. If you want help, you’ll need to highlight which line is line 9. We can’t see line numbers here and, by my count, like 9 is this
local Glitch = Player.PlayerGui:WaitForChild("GlitchEffect")
which wouldn’t be causing that error anyways. So which line has the error?

Its line 9. I still dont even understand the error.

it is

local Glitch = Player.PlayerGui:WaitForChild("GlitchEffect")

Oh, take a look at the docs for TouchEnded:
https://create.roblox.com/docs/reference/engine/classes/BasePart#TouchEnded
partB is nil because TouchEnded only passes a single parameter, hit

sometimes the error would be playergui

I had the error before that too.

You also need to check if Player is nil. Fix those two issues and we’ll see where we’re at.

the thing is am new to coding so basically am learning most things from youtube tutorials or devforum

i got the error

Workspace.Map.GlitchPart.Script:9: attempt to index nil with 'PlayerGui'  -

Could we see a screenshot of the hierarchy where the “GlitchEffect” is placed? This could help understand better the problem