Why doesn't this script work, I even checked if the thing that touches has a humanoid, and even with adding that - I get the same error I had. But why? Why do I even get an error without touching the flag? Here is the script:
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
if player.Team.Name == "Wave" and humanoid.Parent:FindFirstChild("Invincibility") == false then
script.Parent.Parent = humanoid.Parent
local head = humanoid.Parent.Head
script.Parent.CFrame = head.CFrame * CFrame.new(0,2,0)
local weld = Instance.new("Weld")
weld.Part0 = head
weld.C0 = head.CFrame:inverse()
weld.Part1 = script.Parent
weld.C1 = script.Parent.CFrame:inverse()
weld.Parent = script.Parent
script.Parent.Anchored = false
end
end
end)
func = script.Parent.RemoveWeld
function func.OnInvoke()
print(1)
end
Why doesn't it work, and why do I get an error without touching the brick??

2 comments
Try using print as the debug tool.
"Nil Value" means the script doesn't knows what is the value. Meaning the script doesn't knows what the value "Player" is. I am not really good at scripting but try defining player in a different way, I guess.