Anyone know why it clips through the ground when I drop it?
It should just get released where it is when I stop holding down my mouse button
local function press(input, gpa)
if gpa then return end
if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
if renderSteppedConnection ~= nil then return end
local hovering, instance = hoveringOverItem()
if hovering and not instance:FindFirstChild('CarriedBy') and (instance.Parent == items or instance.Parent.Name == 'Plate' or instance.Parent:FindFirstChild('Attachment')) then
carryControls.Visible = true
doorControls.Visible = false
grillProgress.Visible = false
carrying = instance
alignPosition = script.AlignPosition:Clone()
alignPosition.Attachment0 = carrying:FindFirstChild('Attachment')
alignPosition.Parent = carrying
alignOrientation = script.AlignOrientation:Clone()
alignOrientation.Attachment0 = carrying:FindFirstChild('Attachment')
alignOrientation.Parent = carrying
highlight = Instance.new('Highlight')
highlight.FillTransparency = 1
highlight.OutlineColor = Color3.new(0, 0, 0)
highlight.OutlineTransparency = 0
highlight.Adornee = carrying
highlight.DepthMode = Enum.HighlightDepthMode.Occluded
highlight.Parent = carrying
-- carrying.CanCollide = false
carryRemote:FireServer(instance)
renderSteppedConnection = game:GetService('RunService').RenderStepped:Connect(function()
alignPosition.Position = raycast()
alignOrientation.CFrame *= CFrame.Angles(math.rad(vertical*5), math.rad(horizontal*5), 0)
end)
if renderSteppedDoorConnection ~= nil then
renderSteppedDoorConnection:Disconnect()
renderSteppedDoorConnection = nil
end
if renderSteppedProgressConnection ~= nil then
renderSteppedProgressConnection:Disconnect()
renderSteppedProgressConnection = nil
end
end
end
local function release(input, gpa)
if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
if renderSteppedConnection ~= nil then renderSteppedConnection:Disconnect() renderSteppedConnection = nil end
if carrying ~= nil then
carryRemote:FireServer(carrying)
carrying = nil
alignPosition:Destroy()
alignPosition = nil
alignOrientation:Destroy()
alignOrientation = nil
highlight:Destroy()
highlight = nil
-- carrying.CanCollide = true
carryControls.Visible = false
renderSteppedDoorConnection = game:GetService('RunService').RenderStepped:Connect(doorInView)
renderSteppedProgressConnection = game:GetService('RunService').RenderStepped:Connect(grillableInView)
end
end
UserInputService.InputBegan:Connect(press)
UserInputService.InputEnded:Connect(release)
Server
local items = workspace.Items
for _, item in items:GetChildren() do
item:SetNetworkOwner(nil)
end
local carryRemote = game.ReplicatedStorage.Carry
carryRemote.OnServerEvent:Connect(function(player: Player, part: BasePart)
if not part:FindFirstChild('CarriedBy') then
local tag = Instance.new('ObjectValue')
tag.Value = player
tag.Name = 'CarriedBy'
tag.Parent = part
part:SetNetworkOwner(player)
part.CanCollide = false
elseif part:FindFirstChild('CarriedBy').Value == player then
part:FindFirstChild('CarriedBy'):Destroy()
part:SetNetworkOwner(nil)
part.CanCollide = true
end
end)