Grab system not working

Me and my friend macmaniac1234 are working on a game together. This is the problem though. The grabbing.

Whenever we grab someone, line 19 says both of the things are not valid instances.
code:

local Val = nil
game.ReplicatedStorage.FinishAttack.OnServerEvent:Connect(function(Player, Attacker)
		Val = Player
		print("oopsie daisy!")
		print(Player)
		print(Val)
	end)
local function Grab(Player: Model, CharPart: Part)
	local RootPart = Player
	local Animation:Animation = CharPart.Parent:FindFirstChildOfClass("Humanoid"):LoadAnimation(script.Animation)
	Animation:Play()
	if game.Players:GetPlayerFromCharacter(Player.Parent) then
		game.ReplicatedStorage.GrabPlayer:FireClient(game.Players:GetPlayerFromCharacter(Player.Parent))
	end
	repeat
		local Tween: Tween = game:GetService("TweenService"):Create(RootPart, TweenInfo.new(0.01, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {["CFrame"] = CharPart.CFrame + CharPart.CFrame.LookVector * 0.5})
		Tween:Play()
		task.wait()
	until Val.Character.HumanoidRootPart.Name == CharPart.Name
	Val = nil
	CharPart.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = true
	wait(3)
	CharPart.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = false
	return
end

local GrabbedPlayer = nil

game.Players.PlayerAdded:Connect(function(player: Player)

	player.CharacterAdded:Connect(function(character: Model) 
		local Humanoid: Humanoid = character:WaitForChild("Humanoid") or character:FindFirstChildOfClass("Humanoid")
		local Root = character:WaitForChild("HumanoidRootPart");local Head: Part = character:WaitForChild("Head")
		Root.Touched:Connect(function(otherPart: BasePart) 
			if otherPart.Parent:FindFirstChildOfClass("Humanoid") and otherPart:IsA("BasePart") and GrabbedPlayer == nil and otherPart.Parent ~= character and character:WaitForChild("Infected").Value == true and otherPart.Parent:WaitForChild("Infected").Value == false then
				GrabbedPlayer = otherPart.Parent
				Grab(otherPart.Parent:WaitForChild("HumanoidRootPart"), Root)
				print("Done Attacking")
			end
		end)
	end)
end)
1 Like

you can’t instance nil, try until (val and val.Character.HumanoidRootPart.Name == CharPart.Name) or false

t̷̺̲̺̘̻̣̘͚̋̎̎̑͌̎̐̉̚͜ͅḩ̶̛͚̲̗͖̗̲̹̭͙͔̼̐̀̓̈̀͋̐̈́̋̀̕ͅì̴̱̺͕̖̞͖̜̙̗̼̯̘͑͐̄̓̚s̷̡̡̩͚̫͈̯̠̘̣͓̫̣̑̒͂̀̄̔̄́͝͠ͅ ̸̛̲̰͓̅̀̍͑͆̒͒͊̌̚͘͘͠d̸̨̦̲̦̰͍̥̥͓̖̤̦̈́̊̄̅̾̅̕͠͝ę̶͚͙͖̙̪͓̹̐̈́͑̔̈́̇͘͝f̷̤͓̲͗͌̒̈́̽̾̓̌̄͌͝͝͝ì̶̝͓̘̪̎̚̕n̷̡̧̧̺̰̰̰̗͔̯̪̟̮̪̉̑̈́̈́̍̈́͑̇͜ĭ̵̡̯̜̣͖̱̗̝̞̂̊̋̄̕t̵̢̨̳̦̟̳̰͖͖̗̰̘̩̙̅͜͜e̴̢͕͔̯͉̯̯̝͓̝̹̜̹̭͛̈̒̊l̷̻̪̈̍͠y̶̡̛̱͉͎̫̙̹͈͚̰̩̹̦͖̺̋͌̈́̑̀͂͌̚̚͝͝ ̴̡̨͔͖̹̼̙̪͕̒̀̀̎̅́̓͗̈́̊̈́̏̑̓̕͝͝w̶̢̗̫̓̾̈͐̉͂̕̚ͅo̵̡̩͓̺̼̣͂́ŕ̶̨͓̥̝̫̯̰̥̳̭̹̎͛͌͑̈́͐͆̎͆͒̇̕͝͝k̶̮̗̠̯̖̮̭̼̟̰͋̋͋͆̄̓̂̒̅̏̔̃̎͝͝ȩ̷̯̦͊̿͒̉͛̓͜͝͝d̷̡̧̨̢̗̥̟͖͉̭̥̯͉̜͚̜̤̒̉́̇̂͆̅͊̈́͂̅͘̚͝͝ ̸̭̺̹̭̰͇̜͑͌͐͐̒͗̐̎͛̆̓̅̄̽̚̚͜͠1̴̛̬̟̝͍̤̺̋̈͗͐̏͒͗́͆͋̄͑͝0̷͍̦̖̹̜̳̥̟͉̥̤̤̻̝̌̏͐͗̊̓̈́̅́̐͊̆̽͊͘͜0̴̡̝͉͚̦͖̰̤͕͓̻̤̠͍̋͛̇̊͗̇ͅ%̶̡̡̗͕̯̜̫͕̫̼͍̘̯̘͚̠̒̽́̾̓̉́̓̾̕͝ͅ ̵̢̜̮̬͙̰̹͕͚͙̱̭̏͂̔̋̈́͜ş̷̡̡͇̺͖̗̻̬̟̫̋̉̔̏̋̈́̏͗̏̊͂̎́̊̽̃͠o̴̜̜͇̱̟̦͎͚̽̿́͛̈́̂̐͜͜͝͝ ̷̘̞̬̲̯̓̽͊͑͐͂͘s̷̩͚̣̗̭̯̘͑̈́̊̈́̇͐̓̀̾̉̐͝u̸̖̰̠̠̫̔̐̈́͗̾̾̏̐̇̎͘͝͝ŗ̵̛̞͙̮̱̟̹̗̪͍̎̏̔̀́̅̎̎̒̈́̒̓́̾͝e̶̩͔͛͋́͝ ̷͍̪̥̣̲̗̠̟̹͍͍̜̙͇͚̍̍̃̚a̸͖͓̤̭̤̺̭̰̝͚̲̮͖̩̋̌̾̃̃̋̎̆̕b̶̢͋̈́̑̾̀̑͛̓̐́͑̈̉̂̿͝o̷̜͕̝̬̟̳̩̬͕͉̬̺̱͎͉͎̍͒̐̈́́̒̓͘u̵̗̘̲̪̥̳̺̥̘̩̙̟̦̩̒̂͜͠t̴̘̫͕͖̤͇͍̹̜͎̣̯̒͆̔ ̵͖͚͆͑i̴̥̥̬̲̤̇̅͋́̄͒̈̄͝t̵̛̺̟̬̞͕͙̹̬̐̈͐͠ͅ ̸̧̧͉̬̰͍̥͇̪̥̗͒̄̈́̔̕͘͘ͅr̸̻̣͚̩̟̲̉̀͗͜͜e̷̢̛͈̱̦̣̻͓̠̳̘̗̮͉̳̗͚͎͛̃̒́̍̈́͌̽̌̿a̵͉͙̻̱̼̓̎̈́̐̀̓̉̔̌͘ļ̸̡̗͇̜̬̳̖̝̅͊̽̀̈́̑̓͝ (3.5 MB)

it did not