This is my first time making a Placement system, and I watched a YouTube video on how to make a simple one. And was going to add on to it and add rotation when “R” Is pressed on the keyboard, And Every time I try it breaks EVERYTHING and if any one isn’t small brain like me can you help? ![]()
The System works with a Tool and when you click while holding that Tool it places the Object, However I want it to have rotation, Here’s a video of the system.
And heres the script
local RS = game:GetService("ReplicatedStorage")
local placeObject = RS:WaitForChild("PlaceObject")
local placedObjects = workspace:WaitForChild("PlacedObjects")
local objects = RS:WaitForChild("Objects")
local function weld(currentObj)
for objs, obj in pairs(currentObj:GetDescendants()) do
if obj:IsA("BasePart") and obj ~= currentObj.PrimaryPart then
local weldConstraint = Instance.new("WeldConstraint")
weldConstraint.Part0 = obj
weldConstraint.Part1 = currentObj.PrimaryPart
weldConstraint.Parent = obj
obj.Anchored = false
obj.CanCollide = false
end
end
currentObj.PrimaryPart.CanCollide = false
return
end
local function init(obj)
local hitbox = Instance.new("Part")
local orientation, size = obj:GetBoundingBox()
hitbox.Size = size
hitbox.CFrame = orientation
hitbox.Transparency = 1
hitbox.Parent = obj
hitbox.Anchored = true
obj.PrimaryPart = hitbox
weld(obj)
return
end
local function place(obj, posX, posZ)
local orientationY = obj.PrimaryPart.Orientation.Y
obj:SetPrimaryPartCFrame(CFrame.new(posX, obj.PrimaryPart.Position.Y, posZ) * CFrame.Angles(0, math.rad(orientationY), 0))
obj.PrimaryPart.CanCollide = true
return
end
placeObject.OnServerEvent:Connect(function(plr, objectName, posX, posZ)
local foundObject = objects:FindFirstChild(objectName)
if foundObject then
local clonedObject = foundObject:Clone()
init(clonedObject)
place(clonedObject, posX, posZ)
clonedObject.Parent = placedObjects
end
end)
If you could help that would be amazing! but if not its fine thanks anyway! ![]()