Hello guys i'm currently making a game the requires me to have a Part that a player touches and it will remove them from there current job. The only problem is i keep getting this error "Workspace.EndWork.Part.End Work:4: attempt to index local 'Player' (a nil value)"
script.Parent.Touched:connect(function(hit)
local Character = hit.Parent:FindFirstChild("Humanoid")
local Player = game.Players:GetPlayerFromCharacter(Character)
if Player.Core.InWork.Value == true then
Player.Core.InWork.Value = false
Player.TeamColor = game.Teams['Civilian'].TeamColor
print(Player.Name .. " Finished work!")
else
end
end)
Any help would be greatly welcomed. thank you in advanced guys.

2 comments
Does this error occur directly after running the game? or does it occur when you touch the brick?
when you touch the brick