This script basically lets you pick up a flag if you don't have the "Invincibility" tool, and the thing that hits has a humanoid and if the player is on the "Wave" team. And when I touch it I get this error, that doesn't make any sense:
attempt to index local 'player' (a nil value)
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
if humanoid and 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)
func = script.Parent.RemoveWeld
function func.OnInvoke()
print(1)
end
PLEASE HELP

3 comments
I tried, I still get the same error.
Please see the link below:
https://scriptinghelpers.org/questions/67196/attempt-to-index-local-player-a-nil-value