Some Context
In this game I’m allowing VR Users (with big hands) to pick up normal sized player characters. I do this by welding the hand to the character.
The below code is the code for grabbing the player - and it works perfectly!! It allows the VR Person to pick up any player. And I have another script that allows them to drop the player.
The issue arrises if the player dies whilst behind held (beit, reseting or killed by a zombie).
When this happens ANY future player which is attempted to be picked up by this script (and by the same hand) - instantly dies!
Any clues to how I can fix this? I think the issue might be less to do with my script and more to do with how Welds work, which I’ve rarely used so I have no clue what is causing this issue.
Script when a player is picked up:
-- closest = A HumanoidRootPart
-- hand = A part which is controlled by a VR Player
if dist < 3 then -- Checking the magnitude (dist is a magnitude)
if closest:FindFirstChild('Weld') then -- Checking if the player is already held, if so - destroying the old weld
closest.Weld.Part1.Weld:Destroy()
closest.Weld:Destroy()
end
local weld = Instance.new('WeldConstraint')
weld.Part0 = closest
weld.Part1 = hand
weld.Parent = closest
weld.Name = 'Weld'
local ref = Instance.new("ObjectValue")
ref.Name = 'Weld'
ref.Value = weld
ref.Parent = hand
end
If you need more code, or more info - just ask.