Problems a script on the basepale

Hello, I have had some problems trying to program in the basepale, I would like to know how it is possible to make an object appear in the mouse position and only move on the basepale?

I am looking to do something similar to a construction system, that the object appears in the position of the mouse but that they only move in the basepale.

image

I have found this module very helpful and I suggest you look into it too. It has a setting which applies a grid to a plot when you enter build mode and it is super clean, nice and responsive. How to use Placement Service also not many people will give you scripts so you need to probably learn to take parts of modules then put them together to work in a way you want them to.

instance.new(“Part”) and mouse.hit.p

1 Like

Well, you’d need to get the Mouse’s Position obviously

But how would we obtain it?

We can use the :GetMouse() function, which basically gets the Player’s Mouse in a LocalScript:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

The reason why we put it inside a LocalScript is cause the mouse is replicated across the client only, it’s literally your own mouse

Now that we have our mouse depending on your scenario, we can detect when a Mouse gets moved using the MouseMove event so that it moves around the baseplate, and we can get its position using Mouse.Hit.Position so that it’s able to place the part (We can just put it inside ReplicatedStorage for the time being, as we’ll be able to clone it easily):

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Part = game.ReplicatedStorage.PartToClone:Clone()
Part.Parent = workspace

Mouse.MouseMove:Connect(function()
    local MousePos = Mouse.Hit.Position

    Part.Position = MousePos
end)

This should work hopefully?

2 Likes

Thank you very much for your response, sorry for the delay in responding, I had not seen it! I’m going to try and see if it works for me, anything I write you a lot of thanks really

1 Like