So whenever I try to use the script, the output says "Attempting to compare two user data values", and I don't know how to fix it. Can anyone help?
Here's my code:
local tool = script.Parent local mychar local myhum tool.Equipped:connect(function() mychar = tool.Parent myhum = mychar:WaitForChild("Humanoid") myhum.WalkSpeed = 0 hold = myhum:LoadAnimation(tool:WaitForChild("Hold")) hold:Play() for _,part in pairs(workspace:GetChildren()) do if part:IsA("Part") then if part.CFrame <= mychar.Torso.CFrame + Vector3.new(8, 8, 8) then print(part.Name) end end end end) tool.Unequipped:connect(function() hold:Stop() myhum.WalkSpeed = 16 end)
You cannot compare CFrames,
if Part.CFrame <= Otherpart.CFrame then end
Won't work, use magnitude:
if (Part.Position - Otherpart.Position).Magnitude <= 20 then end