How to make client recognize part's position if unanchored

I am trying to make a part grow every time it’s position moves one stud in the Y Axis. (Ex: Player moves a part one stud in the Y Axis, the part will grow by an increment)

The main issue is that when the client moves the part (a sphere) up a ramp, the part will not change its size. But, when the server moves the part, it grows correctly in the client’s perspective.

However, what I’ve found while testing is, if you anchor the part on the client and you move it up it DOES work! That might give some ideas

I think the issue has something to do with the fact that the part is unanchored, since it only works when it is anchored (and moving the part with the move tool sort of realigns the part as if it was anchored…)

(Local Script) :

local part = workspace:WaitForChild("Sphere")
local initialSize = part.Size.X 
local sizeIncrement = 0.01 

local lastPositionY = part.CFrame.Y 

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		game.ReplicatedStorage.Remotes.UpdateOwnership:FireServer(part)
		part:GetPropertyChangedSignal("Position"):Connect(function()
			wait(.1)
			local newY = part.CFrame.Y
			local deltaY = newY - lastPositionY

			if math.abs(deltaY) >= 1 then
				local currentSize = part.Size.X
				local newSize = currentSize + sizeIncrement
				part.Size = Vector3.new(newSize, newSize, newSize)

				lastPositionY = newY
			end
		end)
	end
end)


^ Moving on server works


^ Anchoring on client and then moving works too

1 Like

You’re trying to make a part grow in Roblox when it moves along the Y-axis. The issue is that it only grows correctly when moved by the server, not the client. Anchoring the part on the client seems to fix it. Your code uses a LocalScript to detect when the part is touched and updates its ownership. It then checks if its Y position changed and increases its size if it has. Since it’s a LocalScript, changes are only visible to the player running the script. You could try using a server-side script instead. Have you tried that? Is there a reason you’re using a LocalScript?

I have tried both ways and they face the same problem. I intend to actually make it server-sided but I have to somehow fix this problem first.

Found out how to fix this problem and it’s working exactly like I wanted it to. Basically I just created a “Gyro”. What I did was I made an anchored part that changes its position to the spheres position every second to check if the Y level changed. Pretty simple, I don’t know why I didn’t think of this earlier…

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