Moving part not updating part's position

I place a part which is a sphere on the baseplate. In studio my character kicks the sphere and it rolls, but when I look at the position property of the sphere, it remains unchanged. I thought maybe I needed to publish the game to Roblox and play on Roblox for it to work, but no luck on Roblox either. I cannot find an explanation as to why the part is moving but the position property of the part remains unchanged?

2 Likes

If you unselect the part and select it back again, you will see the updated position.

2 Likes

Interesting. I thought I used to see the part’s position updating in real time without having to unselect and reselect. If you don’t mind me asking another related question, any idea why the following code doesn’t work?

local part = script.Parent
part:GetPropertyChangedSignal(“Position”):Connect(function()
part.BrickColor = BrickColor.new(“Bright red”)
print(“YES Position”)
end)

Thank you. I will mark this as a solution.

Make sure u are doing that on server side

im pretty sure GetPropertyChangedSignal() doesn’t work for some properties. you can do this instead:

local RunService = game:GetService("RunService")
local part = script.Parent
local prevPos = part.Position
local currentPos = part.Position

local minimumChange = .01

local function posChanged()
	print("PosChanged")
end

RunService.Heartbeat:Connect(function()
	currentPos = part.Position
	
	if (currentPos - prevPos).Magnitude > minimumChange then
		posChanged()
	end
	
	prevPos = currentPos
end)

im not sure this will work the best but idk what else you can do

1 Like

This is updated code

local part = script.Parent
part:GetPropertyChangedSignal("Position"):Connect(function()
	part.BrickColor = BrickColor.new("Bright red")
	print("YES Position")
end)

The reason it didnt work is that ur using this ” u should be using this "
Hope that helped

It’s parented to the part in the workspace

I’m just curious as to why GetPropertyChangedSignal() doesn’t work for some properties and also why there are no error messages in the output window?

It didn’t help, that’s not the problem

GetPropertyChangedSignal() doesn’t work for physics - related properties like position

That explains it. Thank you so much!

How? i tested it by myself and it shows an error in the output with ur code

it works fine for me though, i think you are changing the position on client side

i think that if you change the position through a script, like,

part.Position = Vector3.new(10,20,50)

then GetPropertyChangedSignal() works, but if you try to push an unanchored part, even though the position changes the event will not fire

Ohh pushing right, GetPropertyChangedSignal may not always working on some physics. Your approach using heartbeat is nice. You can try this as well

local part = script.Parent
local lastPosition = part.Position

game:GetService(“RunService”).Heartbeat:Connect(function()
if part.Position ~= lastPosition then
print(part.Position)
lastPosition = part.Position
end
end)

1 Like

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