HopperBin script works in studio but won't work in real game. Used to pick up items by clicking on them, and dropping them by clicking again.
holdRadius = 7
maxSelectRadius = 10
local position = Instance.new("BodyPosition")
position.Name = "Pos"
position.maxForce = Vector3.new(100000,100000,100000)
local object = nil
function onButton1Down(mouse)
if mouse.Target ~= nil then
if (mouse.Target.Position - game.Players.LocalPlayer.Character.Head.Position).magnitude <= maxSelectRadius and not mouse.Target.Anchored then
position.Parent = object
position.position = game.Players.LocalPlayer.Character.Head.Position + (mouse.Hit.p - game.Players.LocalPlayer.Character.Head.Position).unit * holdRadius
end
end
function onButton1Up(mouse)
object = nil
position.Parent = nil
down = false
local force = Instance.new("BodyForce")
force.force = Vector3.new(0,90,0)
force.Parent = object
wait(2)
force:Destroy()
end
function onMove(mouse)
if down then
position.position = game.Players.LocalPlayer.Character.Head.Position + (mouse.Hit.p - game.Players.LocalPlayer.Character.Head.Position).unit * holdRadius
end
end
function onSelected(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
mouse.Button1Up:connect(function() onButton1Up(mouse) end)
mouse.Move:connect(function() onMove(mouse) end)
end
script.Parent.Selected:connect(onSelected)
script.Parent.Deselected:connect(onButton1Up)
help?

1 comment
Are you using a local or server script?