my script I am trying to use CFrame to spawn an Instance.new onto the leg.
I will include the FULL script and the parts only directly related to the Cframe. Also, below the fool script is also an explanation about what im trying to do (if you wanna know)
Full Complete script that contains tool variables and functions ETC, I also know next to nothing about CFrame. I have watched videos on it but still dont know how it works.
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local tool = script.Parent
tool.Activated:Connect(function()
wait(0.1)
local MouseTargetParent = Mouse.Target.Parent
print(MouseTargetParent)
local HumanoidFinder = MouseTargetParent:FindFirstChild("Humanoid")
if HumanoidFinder.Name == "Humanoid" then
local leg = HumanoidFinder.Parent:FindFirstChild("LeftLowerLeg")
local Tie = Instance.new("RopeConstraint")
local Rock = Instance.new("Part", workspace)
local AttachmentBase = Instance.new("Attachment")
local AttachmentSide = Instance.new("Attachment")
Tie.Parent = MouseTargetParent:FindFirstChild("LeftLowerLeg")
AttachmentBase.Parent = MouseTargetParent:FindFirstChild("LeftLowerLeg")
AttachmentSide.Parent = Rock
Rock.CFrame = CFrame.new(leg,leg,leg)
Tie.Attachment0 = AttachmentBase
Tie.Attachment1 = AttachmentSide
Tie.Length = 1000
Tie.Visible = true
else do
print("e")
return
end
end
end)
That is the full script that has everything inside it, the purpose is so that when you click someone, a rope gets tied to their legs with a rock as the thing its tied to, in this instance, a rock,
Secondly, The Condensed version (basically a TLDR, Also includes the variables for the attachments + rope!)
tool.Activated:Connect(function()
local leg = HumanoidFinder.Parent:FindFirstChild("LeftLowerLeg")
local Tie = Instance.new("RopeConstraint")
local Rock = Instance.new("Part", workspace)
local AttachmentBase = Instance.new("Attachment")
local AttachmentSide = Instance.new("Attachment")
Tie.Parent = MouseTargetParent:FindFirstChild("LeftLowerLeg")
AttachmentBase.Parent = MouseTargetParent:FindFirstChild("LeftLowerLeg")
AttachmentSide.Parent = Rock
Rock.CFrame = CFrame.new(leg,leg,leg)
Tie.Attachment0 = AttachmentBase
Tie.Attachment1 = AttachmentSide
Tie.Length = 1000
Tie.Visible = true