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)