I have these scripts
server:
local event = script.Parent.Shoot
local dropRight = script.Parent.DropRight
local rightHand = script.Parent.HandR
local TS = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local RightAttached = false
local RightSate = "Stretched"
local LeftAttached = false
local AwaitingRightTouch = true
local RightHolding = false
local PartRightTouch
local PartLeftTouch
local weld = script.Parent.HandR.Grab
local inAnimation = false
event.OnServerEvent:Connect(function(player, side, target)
if side == "Right" and RightHolding == false then
if RightAttached == false then
local Tween = TS:Create(rightHand, tweenInfo, {Position = target})
Tween:Play()
Tween.Completed:Wait()
local touchedConnection
touchedConnection = rightHand.Touched:Connect(function(hit)
if hit and hit.Anchored == false and hit:GetAttribute("Grabable") == true and not MasterDB then
print("first")
AwaitingRightTouch = false
RightSate = "Stretched"
weld.Part0 = hit
hit.Massless = true
hit.CanCollide = false
RightAttached = true
RightHolding = true
PartRightTouch = hit
touchedConnection:Disconnect()
else
task.wait(0.1)
if AwaitingRightTouch == true then
AwaitingRightTouch = false
print("sub")
local Tween = TS:Create(rightHand, tweenInfo, {Position = script.Parent.PosR.Position})
Tween:Play()
Tween.Completed:Wait()
RightAttached = false
AwaitingRightTouch = true
rightHand.Position = script.Parent.PosR.Position
end
end
end)
end
elseif RightAttached == true and RightSate ~= "Holding" then
print("second")
RightSate = "Holding"
local Tween = TS:Create(rightHand, tweenInfo, {Position = script.Parent.PosR.Position})
Tween:Play()
Tween.Completed:Wait()
rightHand.Position = script.Parent.PosR.Position
end
end)
dropRight.OnServerEvent:Connect(function()
MasterDB = true
PartRightTouch.Massless = false
PartRightTouch.CanCollide = true
weld.Part0 = nil
if RightSate == "Holding" then
PartRightTouch.Position = script.Parent.PosR.Position
else
PartRightTouch.Position = rightHand.Position
end
rightHand.Position = script.Parent.PosR.Position
task.wait(1)
RightAttached = false
RightHolding = false
AwaitingRightTouch = true
PartRightTouch = ""
RightSate = ""
MasterDB = false
end)
client:
local UIS = game:GetService("UserInputService")
local tool = script.Parent
local player = game.Players.LocalPlayer
local event = script.Parent.Shoot
local dropRight = script.Parent.DropRight
local rightHand = script.Parent.HandR
local equipped = false
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
end)
UIS.InputBegan:Connect(function(input)
if input and input.KeyCode == Enum.KeyCode.E and equipped == true then
print("E PRESSED")
local mouse = player:GetMouse()
local target = mouse.Hit.Position
local Distance = (mouse.Hit.Position - player.Character.HumanoidRootPart.Position).Magnitude
if not mouse.Target or Distance >= 40 then return end
event:FireServer("Right", target)
else if input and input.KeyCode == Enum.KeyCode.F and equipped == true then
dropRight:FireServer()
end
end
end)
These are making a sort of grabbing system, where the hand that shoots from your character (its a part within a tool) welds onto a part and if it matches some criteria it sticks and you can move it, drop it, or drag it in. This works however not the way i want it to.
Currently it just uses welds, this means if I hid the part in the top right hand corner the whole part will teleport to that the hit position in the top right hand corner is not the center of the part. To which it will not weld. Also if the part is big and i pull it in, it will be inside the players character and look weird.
Weld constraints give me the desired result however you cannot Tween parts welded together using weld constraints with CFrame. which is what i need so that the parts welded would actually move along with the hand.
I’m asking if there is a way i can get my desired result, which is welding such as with Weld Constraints but also to keep the ability to tween using CFrame. I might also add that both parts, the hand and the part it welds to will always be unanchored
Any help is appreciated