While scripting in studio, I encountered a bug, that I don’t know how to fix
(baseplate is anchored, object that’s being placed bugs when it’s anchored AND when it’s unanchored)
An error occours when uploading a video, so I will show screenshots.
It’s changing postion/orientation, the spawn is above the ground when it was normal before I clicked.
When I removed the welding part of the script, when placing objects, it didn’t shake the baseplate/part that’s being clicked on
script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlaceRemoteEvent = ReplicatedStorage.RemoteEvents.PlaceRemote
local DestroyRemoteEvent = ReplicatedStorage.RemoteEvents.DestroyRemote
PlaceRemoteEvent.OnServerEvent:Connect(function(Player,partPos,block,surface,target)
local part = ReplicatedStorage.PlaceSystemObjects.Thruster:Clone()
--local part = ReplicatedStorage.PlaceSystemObjects.Block:Clone()
--local part = ReplicatedStorage.PlaceSystemObjects.Barrel:Clone()
part.Parent = workspace
local children = part:GetChildren()
local addX = 0 -- addX, addY, addZ adds to the position of the new instance
local addY = 0
local addZ = 0
for i,v in pairs(children) do
--v.Anchored = true
--v:SetNetworkOwner()
part:SetAttribute("CreatedByPlayer",true)
part:SetAttribute("Owner",""..tostring(Player))
local sizeX = v.Size.X
local sizeY = v.Size.Y
local sizeZ = v.Size.Z
if surface == Enum.NormalId.Top then
addY = sizeY/2
elseif surface == Enum.NormalId.Bottom then
addY = -sizeY/2
elseif surface == Enum.NormalId.Front then
addZ = -sizeZ/2
elseif surface == Enum.NormalId.Back then
addZ = sizeZ/2
elseif surface == Enum.NormalId.Right then
addX = sizeX/2
elseif surface == Enum.NormalId.Left then
addX = -sizeX/2
end
local posX = partPos.X + addX
local posY = partPos.Y + addY
local posZ = partPos.Z + addZ
part:PivotTo(CFrame.new(Vector3.new(posX,posY,posZ)))
task.wait()
local weld = Instance.new("WeldConstraint")
weld.Parent = part.hitbox
weld.Part1 = target
weld.Part0 = part.hitbox
--print(children[1])
end
--print(block," ",surface)
end)
DestroyRemoteEvent.OnServerEvent:Connect(function(player, targetToDestroy)
if targetToDestroy.Parent.ClassName == "Model" and targetToDestroy.Parent:GetAttribute("CreatedByPlayer") == true and targetToDestroy.Parent:GetAttribute("Owner") == ""..tostring(player) then
targetToDestroy.Parent:Destroy()
end
end)