Part's size not being displayed correctly?

In my game, you stack moving blocks and any overhang from the previous block should be cut and unanchored. I achieve this by creating two separate blocks upon placement: one part for the side to be unanchored and one for the part that stays on.

The issue though is that when there is a significant overhang quite early on, this happens:

The part that’s meant to stay on doesn’t change size or position.

This has caused tons of confusion as when I print the size, it says that the size of the block is what it was meant to be even though that’s not what’s being displayed. Even more confusing, I send the properties of the block to the server through a RemoteEvent (Size, Position, Color) so it can be displayed to everyone else, and when I do in this case, it shows as intended:

This issue doesn’t happen when the overhang is not as much.

I’ve tried re-writes and stuff, and also tried to find relevant Dev Forum posts but I still can’t figure out this issue, the code is here:

				--script that occurs when block is placed
				local function distance(num1,num2)
		        	local dist = num1-num2
		        	if dist<0 then dist = dist*-1 end
		        	return dist
	        	end
				
				local style = ""

				local MovingFarOne = Vector3.new(stack.MovingPart.Position.X+(stack.MovingPart.Size.X/2),stack.MovingPart.Position.Y,stack.MovingPart.Position.Z) --Gets the position of the left-most X side of the moving block
				local MovingFarTwo = Vector3.new(stack.MovingPart.Position.X-(stack.MovingPart.Size.X/2),stack.MovingPart.Position.Y,stack.MovingPart.Position.Z) --Gets the position of the right-most X side of the moving block
				local NewFarOne = Vector3.new(stack.NewestPart.Position.X+(stack.NewestPart.Size.X/2),stack.NewestPart.Position.Y,stack.NewestPart.Position.Z) --Gets the position of the left-most X side of the previous block
				local NewFarTwo = Vector3.new(stack.NewestPart.Position.X-(stack.NewestPart.Size.X/2),stack.NewestPart.Position.Y,stack.NewestPart.Position.Z) --Gets the position of the right-most X side of the previous block

				if MovingFarOne.X>NewFarOne.X and MovingFarTwo.X<NewFarOne.X then
					style = "CutOne" --Overhang at the left side
				elseif MovingFarTwo.X<NewFarTwo.X and MovingFarOne.X>NewFarTwo.X then
					style = "CutTwo" --Overhang at the right side
				elseif stack.MovingPart.Position.X == stack.NewestPart.Position.X then
					style = "Perfect" --No overhang
				else
					style = "GameOver"
				end

				if style == "CutOne" then --The issue applies to all "styles"
					local lengthofoverhang = distance(MovingFarOne.X,NewFarOne.X) --gets distance of overhang
					
					local newblock = stack.MovingPart:Clone()
					newblock.Parent = stack
					newblock.Size -= Vector3.new(lengthofoverhang,0,0)
					newblock.Position = Vector3.new(NewFarOne.X-(newblock.Size.X/2),newblock.Position.Y,newblock.Position.Z)
					newblock.Name = "TempName"
					newblock.Slam:Play()

					local stackoverhang = stack.MovingPart
					stackoverhang.Name = "deb"
					stackoverhang.Parent = workspace.Debris
					stackoverhang.Size = Vector3.new(lengthofoverhang,stackoverhang.Size.Y,stackoverhang.Size.Z)
					stackoverhang.Position = Vector3.new(NewFarOne.X+(lengthofoverhang/2),newblock.Position.Y,newblock.Position.Z)
					stackoverhang.CanCollide = false
					stackoverhang.Anchored = false

					newblock.Name = "MovingPart"
					rs.Remotes.Stack.StackReceive:FireServer({newblock.Position,newblock.Color,newblock.Size}) --sends information
					return
				elseif --continues here

I do know the issue isn’t a result of the “style” being incorrect, nor the overhang not being unanchored. It just looks like the part’s size/position isn’t being displayed right?

Honestly your explanation confused me, I do not quite get the issue regarding your script.

1 Like

Basically, I set a part’s size & position through a LocalScript and it didn’t show any change to it, even though the properties of the part was changed accordingly.

1 Like

Why are you changing size and position through a LocalScript? Do you not want it to replicate to other players? If you do, then you should do it on a server script. Doing it through a local script will only change it visually on the client and not for anyone else.

1 Like

It used to be like this, although since the game requires player inputs to stack the blocks, doing things through the server resulted in significant delay between the input and the block being stacked. It was much better to have things done locally and to just send the block information to the server with a RemoteEvent.

After sending the block information to the server, do you also update the blocks properties on the server? Else it won’t be updated to the other players in the game and also wont be visible to the server.

Yeah. My issue right now though is that despite the properties of the block being sent to the server and set correctly, the same block with the same properties appears unedited locally. An example of this is shown in the pictures attached to the original post.

Btw a player’s own “stack” in the server isn’t visible to them.

You may be applying the transformation twice, once on the client and once on the server. Thus the server will display properly, since it goes client → server, but the server transformation also replicates back to the client so for the client it’d be going client → client + server. It looks to me like the part is being halved, which would make sense if this is the case.

Probably not, because when the part’s information is sent to the server, it just sends the necessary properties which are just the Size, Position and Color of the block. The server then creates a completely new part using Instance.new() then just sets the properties accordingly, that new part is then just deleted on the client.

Because the stack game happens exclusively on the client, whatever parts the player sees and are playing the game with aren’t seen by the server.

Not sure if that’s what you meant but yeah.

Pretty sure it’s a replication issue either way. You should analyze the properties of all the parts, to see if you’re performing some math wrong maybe. But I think it’s replication

The issue was a tweening issue elsewhere from the script.

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