Hi, I’m working on a part-movement tool.
The way it works is to move the parts locally and send the moved parts and the location values of the parts to the server and apply them on the server as well.
I want the parts to be moved only within a certain area.
So the way I thought of it was to use Region 3 to apply the part position when the part position value is within the zone position, and to return the part position to the pre-movement position when it is outside the position.
However, as far as I know, Region 3 is no longer used. So I need an alternative, and I don’t know what to do.
Please help…
This code is the code that will be the base for that functionality.
local toolEvent = ReplicatedStorage:WaitForChild("ToolEvent")
toolEvent.OnServerEvent:Connect(function(player, target, newCFrame)
local originPosition = target.Position
local testpart = TierModel.testpart
if target and newCFrame then
target.Position = newCFrame
end
end)
A better choice to Region3 is using :GetPartsInPart(), which detects any parts that enter the part. This won’t work if the zone area has the CanCollide property set to true. Here’s an example of how it should look like.
local Part = game.Workspace:WaitForChild("ee") -- change to your part
local FilterParts = {} -- anything you want to be filtered
local Params = OverlapParams.new() -- add more to the params if you want
Params.FilterType = Enum.RaycastFilterType.Exclude
Params:AddToFilter(FilterParts)
while task.wait() do
local PartsInPart = game.Workspace:GetPartsInPart(Part, Params)
for Index, DetectedPart in pairs(PartsInPart) do
if DetectedPart.Name == Part.Name then continue end
if DetectedPart.Name == "YourPartName" then -- change this to your part's name
print("Success!")
end
end
end