Im trying to make a tool that when you click it will cast a big hitbox and freeze every player that touched it.
However I’m not sure how to do this I’m attempting to use for i,v in pairs to go through each player but it gives me an error that says "invalid argument #1 to pairs (table expected, got Instance)
I’d like to know if im doing this wrong or if theres a better method of going through each character.
local HitBox = box:Clone()
HitBox.Parent = plr.Character
HitBox.CFrame = plr.Character.HumanoidRootPart.CFrame
HitBox.Touched:Connect(function(hit)
for i,v in pairs (hit) do
if v == plr then return end -- to ignore the player who used the tool
if v.Parent:FindFirstChild("Humanoid") then
v.Parent.Humanoid.WalkSpeed = 0
v.Parent.Humanoid.JumpPower = 0
v.Parent.Humanoid.AutoRotate = false
v.Parent.HumanoidRootPart.Anchored = true
end
end
end)
task.wait(0.1)
HitBox:Destroy()