Weird part physics glitch

I have this grab script here, and the part freezes in mid air when the position changes, When it should be falling.


Here is the script.

local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer
local mouse = plr:GetMouse()
local campos = game:GetService("Workspace").CurrentCamera.CFrame.Position

local buttondown = false
local render = game:GetService("RunService")
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
--part.Position = (cf + cf.LookVector * 3).Position

wait(5)

mouse.Button1Down:Connect(function()
	buttondown = true
end)

mouse.Button1Up:Connect(function()
	buttondown = false
end)


function place(part)

	local cf = CFrame.new(plr.Character.Head.Position, mouse.Hit.Position)
	local t = ts:Create(part, ti, {CFrame =(cf + cf.LookVector * 5) })
	t:Play()
	--part.Position = (cf + cf.LookVector * 5).Position
end
render.Heartbeat:Connect(function()
	if buttondown == true and mouse.Target then
		
		if mouse.Target.Parent == workspace.parts then
			local part = mouse.Target
			place(part)
			
		end
		
		
		
	end
end)

What can I do to make the part fall like normal?

2 Likes

Maybe it’s because you are setting the position constantly, so it cannot fall. This is just a guess so I’m not sure if this is the real reason.

Maybe is simply better to use dragdetector DragDetector | Documentation - Roblox Creator Hub

it only happens when you hold down, so i don’t think thats the problem

It only sets the position while holding the mouse down, but I’m not sure. Maybe you can try @brenorocketstar’s method.

woah i had no idea that this existed, thanks.

It is new. Probably better than a localscript since it is native to Roblox.

I had this issue when making an item grab system for my game. When the player attempted to drop an item, it would just hang in the air like you example in the video.

The issue was that the item’s network ownership was the server, but I was moving the part through local scripts (the client).

The fix was to set the item’s network ownership to the player when they grabbed it. (In this case the item was a model, so I set the network ownership of the model’s primary part to the player)

Another solution was to apply a large enough force to the item after dropping it. I opted for the first solution.

Edit: Clarification

for some reason some parts will work, and others will not. Despite having the player be the network owner.

local plr = game:GetService("Players").PlayerAdded:Wait()
wait()
for i,v in pairs(script.Parent:GetChildren()) do
	v:SetNetworkOwner(plr)
end
	

Do you know if there is any reason for this?
(this is inside a folder in the workspace by the way)

I think it only works for some parts because the code hits an error: when you loop through the folder’s children, that also includes the script.

Scripts don’t have a function call :SetNetworkOwner(), so it errors, and the loop stops. Some parts probably got their network ownership set correctly, but then it broke when it reached the script object, leaving some part’s network ownership to not be set to the player.

To fix it, make sure the child you are indexing is a BasePart as so:

local plr = game:GetService("Players").PlayerAdded:Wait()
wait()
for i,v in pairs(script.Parent:GetChildren()) do
	if v:IsA("BasePart") then
		v:SetNetworkOwner(player)
	end
end

I tried, and the network ownership still shows up as black for some reason. I even tried looping it so it keeps resetting the ownership, but it doesn’t work.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.