✓ Accepted answer
this is really buggy actually sorry :( but heres what i have so far
local script:
local mouse = game.Players.LocalPlayer:GetMouse()
local Click = false
mouse.Button1Down:Connect(function() Click = true end)
mouse.Button1Up:Connect(function() Click = false end)
local loop = true
local target
mouse.Move:Connect(function()
if loop == false and Click == true then
if mouse.Target then
target = mouse.Target
local x,y,z = mouse.Hit.x, mouse.Hit.Y, mouse.Hit.Z
game.ReplicatedStorage.NewPos:FireServer(Vector3.new(x,y,z), mouse.Target)
end
end
end)
while true do
if mouse.Target == nil then
game.ReplicatedStorage.StopDragging:FireServer(target)
Click = false
else
target = mouse.Target
end
if Click == false then
game.ReplicatedStorage.StopDragging:FireServer(target)
end
if Click == true and loop == true then
if mouse.Target then
if mouse.Target:FindFirstChild("Draggable") then
local x,y,z = mouse.Hit.x, mouse.Hit.Y, mouse.Hit.Z
game.ReplicatedStorage.StartDragging:FireServer(Vector3.new(x,y,z), mouse.Target)
loop = false
end
end
end
wait()
end
serverScript:
local dragger = script.Dragger:Clone()
game.ReplicatedStorage.StartDragging.OnServerEvent:Connect(function(plr, Position, Object)
local weld = Instance.new("Weld")
local bp = Instance.new("BodyPosition")
if Object:IsA("Model") then
weld.Part0 = Object.PrimaryPart
dragger.Parent = Object
weld.Part1 = dragger
else
weld.Part0 = Object
dragger.Parent = Object
dragger.Position = Object.Position + Vector3.new(Object.Size.X + 0.05, Object.Size.Y + 0.05, Object.Size.Z + 0.05)
weld.Part1 = dragger
end
bp.Parent = dragger
bp.Position = Position
weld.Parent = dragger
end)
game.ReplicatedStorage.NewPos.OnServerEvent:Connect(function(plr, Position, Object)
if Object:FindFirstChild("Dragger") then
Object.Dragger.BodyPosition.Position = Position
end
game.ReplicatedStorage.StopDragging.OnServerEvent:Connect(function(plr, object)
if Object:FindFirstChild("Dragger") then
Object.Dragger:Destroy()
end
end)
end)
4 comments
it'll be a while but i can tell you what you're doing wrong just hold on (like 10 - 20 mins)
Aye, thank m8!
Thanks*
nevermind, figured it out. Thanks anyway!