#How to fix the bouncing
1 messages · Page 1 of 1 (latest)
Drag_Controller:
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Drag_Controller = {}
local dragData = {}
local player = Players.LocalPlayer
local remote = ReplicatedStorage.Remotes.DragNetworkControl
local currentHighlight = nil
local currentTarget = nil
local highlightOBJ = ReplicatedStorage.Game_Objects.HoverHighlight
local draggableFolder
function Drag_Controller.Setup(folder: Instance)
draggableFolder = folder
for _, part in folder:GetChildren() do
if part:IsA("BasePart") then
local detector = part:FindFirstChildOfClass("DragDetector") or Instance.new("DragDetector")
detector.Parent = part
detector.DragStart:Connect(function()
dragData[part] = true
remote:FireServer(part, true) -- Request ownership once
end)
detector.DragEnd:Connect(function()
dragData[part] = false
remote:FireServer(part, false) -- Release ownership
end)
end
end
end
RunService.RenderStepped:Connect(function()
local character = player.Character
local hrp = character and character:FindFirstChild("HumanoidRootPart")
local mouse = player:GetMouse()
local target = mouse.Target
-- Hover highlight
if target and target:IsA("BasePart") and target:IsDescendantOf(draggableFolder) and not dragData[target] then
if target ~= currentTarget then
if currentHighlight then
currentHighlight:Destroy()
end
currentTarget = target
currentHighlight = highlightOBJ:Clone()
currentHighlight.Adornee = target
currentHighlight.Parent = target
end
else
if currentHighlight then
currentHighlight:Destroy()
currentHighlight = nil
end
currentTarget = nil
end
-- Move dragged parts
for part, dragging in pairs(dragData) do
if dragging and part:IsDescendantOf(workspace) and hrp then
local forwardPos = hrp.Position + hrp.CFrame.LookVector * 6
part.Position = part.Position:Lerp(forwardPos, 0.2)
end
end
end)
return Drag_Controller
server:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage.Remotes.DragNetworkControl
event.OnServerEvent:Connect(function(player, part: BasePart, shouldOwn: boolean)
if part:IsDescendantOf(workspace) and part:IsA("BasePart") then
if shouldOwn then
part:SetNetworkOwner(player)
print("Set network ownership to: " .. player.Name)
end
end
end)
okay leme debu
debug
hmm i never worked with drag detectors
so this might take a while
aight ok
but this it what it looks like when i test
i think i need to use vieworplane not sure
k
lemme check
but scriptable didnt really do anything