--//// Varibles
--// Config
local DragForce = 300
--// Important
local Player = game.Players.LocalPlayer
--// Services
local RunService = game:GetService("RunService")
--// Other
local Mouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local Dragging = false
local CurrentObject = nil
local CurrentMover = nil
--//// Script
--// Functions
--// Script
Mouse.Button1Down:Connect(function()
local Target = Mouse.Target
if Target then
if Target.Anchored == false then
local mvr = Instance.new("BodyPosition")
CurrentObject = Target
CurrentMover = mvr
--CurrentMover.P = DragForce
CurrentMover.D = 100
CurrentMover.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
CurrentMover.Parent = CurrentObject
script.RemoteEvent:FireServer("SetNetwork",CurrentObject)
end
end
end)
Mouse.Button1Up:Connect(function()
if CurrentObject and CurrentMover then
CurrentObject:FindFirstChildWhichIsA("BodyPosition"):Destroy()
CurrentObject = nil
end
end)
RunService.RenderStepped:Connect(function()
if CurrentObject and CurrentMover then
local Goal = Camera.CFrame.Position+(Camera.CFrame.LookVector-Mouse.Hit.Position).Unit*15
--CurrentBodyMover.Force = Goal
CurrentMover.Position = Goal
print(tostring(Goal))
end
end)
servor
script.Parent.OnServerEvent:Connect(function(Player,Act,Obj)
if Act == "SetNetwork" then
Obj:SetNetworkOwner(Player)
end
end)
I would recommend using AlignPosition I used it in remaking my Drag system recently before I used BodyPosition like you.BodyPosition is deprecated but It should be working
I created a Cursor that followed the mouse at all times. and Then I create Two attachments one I place in my cursor and then another into the part where i also put the AlignPosition Constraint. Its a lot of code because it was tinkered a lot DraggingGif
It would be easier to show you my old code using body movers
I am deleting lines here and there but here’s some examples
ClientSide Pickup Example
local Mouse = Player:GetMouse()
local Mass = Object:GetMass() local MForce = Vector3.new(math.huge,math.huge,math.huge)--50000,50000,50000)
local BP = Instance.new("BodyPosition") BP.Parent = Object BP.Name = 'Telekinesis'
BP.Position = Mouse.Hit.Position BP.P = 450 BP.D = 50
BP.MaxForce = MForce
local BAV = Instance.new("BodyAngularVelocity")
BAV.Name = "AngleStabilizer"
BAV.AngularVelocity = Vector3.new(0,0,0)
BAV.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
BAV.P = 250
BAV.Parent = Object
Serverside PickUp
local Holding = workspace.MouseTargetFilterStorage.Players.Players_Telekinesis[Player.Name].Holding
local HoldingChildren = Holding:GetChildren()
if #HoldingChildren == 0 then
if Object.ClassName == "Model" then
local ObjectWithin = Object.PrimaryPart
Object.Parent = Holding
print('Test2')
ObjectWithin:SetNetworkOwner(Player)
else
Object:SetNetworkOwner(Player)
Object.Parent = Holding
print('Test1')
end
end
ServerSide Dropping
TelekinesisModule.CleanObject(Player,Object,SecObj)
local Holding = workspace.MouseTargetFilterStorage.Players.Players_Telekinesis[Player.Name].Holding
local HoldingChildren = Holding:GetChildren()
if #HoldingChildren ~= 0 then
if Object and Object:IsA('Model') then
local ObjectWithin = Object.PrimaryPart
Object.Parent = workspace.Interactable
ObjectWithin:SetNetworkOwner(nil)
else
Object.Parent = workspace.Interactable
Object:SetNetworkOwner(nil)
end
end
Moving Part Around
RunService.RenderStepped:connect(function()
if Object:FindFirstChild('Telekinesis') then
local TelePos = Character.Head.Position + (Mouse.Hit.p - Character.Head.Position).unit* Distance
Object.Telekinesis.Position = position
end
end
end)
but yea here’s roughly the system not it entirely but maybe it could help ask me any questions you may have
i tried to set the position to the mosue hit position, and it just didn’t work
i have a feeling that theres not something wrong with my script and the game itsself, i could give you the place file if you want so you can check the script better or something
Its okay we probably could get it working just from a few messages. Just to double check no errors right? have you tried picking up something and checking explorer to see if the body movers were added.
I would remove the button-Up** function or at least comment it out right now and click a part and then open explorer and click on the body mover and edit its properties live as you test
I think you just need to mess around in playtesting to see what the issue could be like clicking on the part looking at the bodymover live. Have you tried?
so that you can edit the bodymovers properties and find out what was wrong rereading and I noticed what was different from your code and my example you never set the Pressure(p)Property so there’s no force moving the body mover.