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
You're problem is rather simple.
attempt to index local 'player' (a nil value)
means that your variable player is nil (not true or false. It's non existent).
I see you just straight up use the touched function, but seeing as you're dealing with players, expect the game to register touching with parts in the environment. E.I: Baseplate, the floor, whatever the flag is on, a wall.
To fix this, add this line:
if humanoid then -- define your player, and do everything else.