You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
i want my props to be able to be parented to another part without getting destroyed -
What is the issue? Include screenshots / videos if possible!
i have 2 scripts that place props, they use the exact same code but only one works. after alot of debugging i found out that parenting to the part makes it so that it gets destroyed but the other script does that without getting destroyed -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i have tried everything on devforum and i even turned locked on but it still got destroyed
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- This is an example Lua code block
local function placeProp(Part:BasePart,prop,offset:number,rotate : boolean,seed)
task.wait()
local RandomService = Random.new(seed)
local propMultiplier = RandomService.NextNumber(RandomService,0.8,1.2)
local adjustedHeight = 1
local newProp = prop:Clone()
if newProp:IsA("BasePart") then
adjustedHeight = (Part.Size.Y / 2)+ ((prop.Size.Y * propMultiplier) / 2)
local x = Part.Position.X + RandomService.NextInteger(RandomService,-(Part.Size.X / 1.25)/2,(Part.Size.X / 1.25)/2)
local z = Part.Position.Z + RandomService.NextInteger(RandomService,-(Part.Size.Z / 1.25)/2,(Part.Size.Z / 1.25)/2)
local adjustedPosition = Vector3.new(x,((Part.Position.Y + adjustedHeight)- offset),z)
local orient = newProp.Orientation
if rotate == true then
orient = Vector3.new(newProp.Orientation.X,RandomService.NextInteger(RandomService,0,360),newProp.Orientation.Z)
end
newProp.Orientation = orient
newProp.Size *= propMultiplier
newProp.Position = adjustedPosition
newProp.Parent = Part
elseif newProp:IsA("Model") then
local x = Part.Position.X + RandomService.NextInteger(RandomService,-(Part.Size.X / 1.25)/2,(Part.Size.X / 1.25)/2)
local z = Part.Position.Z + RandomService.NextInteger(RandomService,-(Part.Size.Z / 1.25)/2,(Part.Size.Z / 1.25)/2)
adjustedHeight = (Part.Size.Y / 2)+ ((prop.PrimaryPart.Size.Y * propMultiplier) / 2)
local adjustedPosition = Vector3.new(x,((Part.Position.Y + adjustedHeight)- offset),z)
local xr,yr,zr = newProp:GetPivot():ToOrientation()
if rotate == true then
xr,yr,zr = newProp:GetPivot():ToOrientation().X,RandomService.NextInteger(RandomService,0,360),newProp:GetPivot():ToOrientation().Z
end
newProp:PivotTo(CFrame.new(adjustedPosition) * CFrame.Angles(xr,yr,zr))
for i,v in pairs(newProp:GetChildren()) do
if v:IsA("BasePart") then
v.Size *= propMultiplier
end
end
newProp.Parent = Part
end
end