How make Part That can be Grabble Be on Baseplate TopSurface?

look my problem

the one that was in the same place is the original part Size and what i toke from button is the secend and his size is small i want the part be on THE BASEPLATE NOT HALF ON IT

help

GUI Script :

local Player = game:GetService(“Players”).LocalPlayer
local Mouse = Player:GetMouse()
local UIS = game:GetService(“UserInputService”)
local Building = false

script.Parent.MouseButton1Click:Connect(function()
Wall = game.ReplicatedStorage.Wall:Clone()
Wall.Transparency = 0.5
Wall.CanCollide = false
Wall.Anchored = true

Wall.Parent = workspace
Building = true

end)

UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 and Building then
Building = false
Wall.Transparency = 0
Wall.CanCollide = true
Wall.Anchored = true
end
end)

Mouse.Move:Connect(function()
if Building then
local MousePositionIn3DSpace = Mouse.Hit.p
Wall.Position = Vector3.new(MousePositionIn3DSpace.X, .5 , MousePositionIn3DSpace.Z)
end
end)

Check this post out:

1 Like

first they not rotated and what you mean Part.Size.Y/2???

Can you take my scripts and try fix it if you can i appreciate it

Artum, this is not exactly the proper way to utilize DevForum. DevForum is a community of developers here to assist you incase you have a problem. It’s a place to build upon each other until a solution is found.

It’s not a place to just ask someone else to fix it for you and give it back when they are finished. It is also generally recommended that you more professionally format your posts for easier readability.

But to answer your question, the Y size of a part is the height of that part. When you divide that size by 2 you can get the position of the edge of that surface of that part which you can compare to the Y/2 of the baseplate put with the position to get the top surface and then see if its the same (or in other words on top of each other)

I’m guessing you meant that you wanted the part to be on top of the baseplate and not half-sunken into it…

You have to look into the properties of game.ReplicatedStorage.Wall, then go to the Size property of it. Look at the middle of the 3 numbers. The one in the middle is the Y value, and it dictates how tall a part is. You have to take that middle number and divide it by 2. Copy the result, and go back to this part of the script.

Mouse.Move:Connect(function()
if Building then
local MousePositionIn3DSpace = Mouse.Hit.p
Wall.Position = Vector3.new(MousePositionIn3DSpace.X, .5 , MousePositionIn3DSpace.Z)
end
end)

Focus on this part. Wall.Position = Vector3.new(MousePositionIn3DSpace.X, .5 , MousePositionIn3DSpace.Z)

Move to the .5 part of it, and then replace that number with the number that you saved. Hopefully, I helped.

1 Like

Here’s a tweak to your mouse move function:

Mouse.Move:Connect(function()
if Building then
local MousePositionIn3DSpace = Mouse.Hit.p
Wall.Position = Vector3.new(MousePositionIn3DSpace.X, Wall.Size.Y, MousePositionIn3DSpace.Z)
end
end)

Using Wall.Size.Y as the offset keeps the offset constant no matter what size you make the wall.

I think there was something wrong there. You have to do this:
Wall.Position = MousePositionIn3DSpace + Vector3.new(0,,0)
then insert the number in between the two commas.

Could you please repeat that? I can’t understand.