Hey there, this is a LocalScript in a tool, What this script does is grabs un-anchored Models, (like the move tool) The problem here is, that it picks up Humanoids, is there a way I can put in a function, IF the model contains a Humanoid don't do anything? I am not really sure how to implement this in code form?
Any help please?
local bin = script.Parent
local bp = Instance.new("BodyPosition")
bp.maxForce=Vector3.new(math.huge, math.huge, math.huge)
local movecon = nil
local bpfixcon = nil
function onchanged(prop, mouse)
if bp.Parent ~= nil then
if mouse.Hit ~= nil and mouse.Target ~= nil then
bp.position=mouse.Hit.p-(mouse.Hit.lookVector*bp.Parent.Size.Y)
end
end
end
function onclickdown(mouse)
if mouse.Target ~= nil then
if mouse.Target.Anchored==false then
if bp == nil then
bp = Instance.new("BodyPosition")
bp.maxForce=Vector3.new(math.huge, math.huge, math.huge)--bp.maxForce*700
bpfixcon:disconnect()
bpfixcon = bp.Changed:connect(fixbp)
end
bp.Parent=mouse.Target
bp.position=mouse.Target.Position
if bp.Parent.Parent.ClassName~="Model" then
mouse.TargetFilter=bp.Parent
else
mouse.TargetFilter=bp.Parent.Parent
end
movecon = game:GetService("RunService").Stepped:connect(function(f) onchanged(f, mouse) end)
end
end
end
function onclickup(mouse)
bp.Parent=nil
mouse.TargetFilter=nil
if movecon ~= nil then
movecon:disconnect()
movecon=nil
end
end
function fixbp(prop)
if bp == nil then
bp = Instance.new("BodyPosition")
bp.maxForce=Vector3.new(math.huge, math.huge, math.huge)--bp.maxForce*700
bpfixcon:disconnect()
bpfixcon = bp.Changed:connect(fixbp)
end
end
function onselected(mouse)
--movecon = game:GetService("RunService").Stepped:connect(function(f) onchanged(f, mouse) end)
mouse.Button1Down:connect(function() onclickdown(mouse) end)
mouse.Button1Up:connect(function() onclickup(mouse) end)
end
bin.Selected:connect(onselected)

4 comments
For some reason it still picks up Humanoids?
Re-positioned my end. Try again.
still doesnt work D:
Put another way to do that thing. Try once again.