Hello all,
I’ve been trying to write a script where when you touch a part, it rotates your hand (The hand is a model made by me). So far I’ve tried using CFrame angels, but have had no luck doing so, have set the model PrimaryPart and tried rotating the model with the primary part, but had yet again no success. No errors, just nothing happening. The model is inside the character, so I use hit.Parent.GloveHandRight to make actions to the parts inside the hand etc. I would also union these, but am planning animations for the hands such as a fist, grip and idle animation. If anyone could give some advice on how to achieve this, it would be greatly appreciated.
The code for touch event:
partThing.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and debounce == false then
--Variables
debounce = true --Checking if part can clone again (no)
local partClone = partThing:Clone() --Part clone
local gloveR = hit.Parent.GloveHandRight --Gets right hand
local HRP = hit.Parent.GloveHandRight.HandRootPart --Root part of hand
--Checkpoint 1
partClone.Name = partThing.Name .. "Cloned" --Setting Name
print("Cloned " .. partClone.Name) --Letting me know the code worked
--Setting Basics
partClone.Parent = hit.Parent.GloveHandRight --Adding the part to hand
partClone.CanCollide = false --Disabling CanCollied (let's you walk thorugh it)
partClone.Anchored = false
--Creating weld
local newWeld = Instance.new("WeldConstraint", partClone) --Creates new weld
newWeld.Part0 = hit.Parent.GloveHandRight.pickupPartCloned --Sets cloned part as main part
newWeld.Part1 = HRP --Welds part to HRP
--Rotates Hand
gloveR.PrimaryPart = gloveR.HandRootPart
--Resizng & Position
partClone.Position = hit.Parent.GloveHandRight.HandRootPart.Position --Sets Position
partClone.Size = partClone.Size/3
end
end)
If anyone needs images of what the hands look like, or how the explorer is laid out, here you go:
Any help is highly appreciated, thanks!
-TaboDev