Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

(Still Unanswered) CFrame is not working correctly, doesnt "spawn" the part at the desired area?

In 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

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
		
		

 

2 comments

0

Sorry if this post is too long, I just need some help, CFrame is hard man :C

0

"Rock.CFrame = CFrame.new(leg,leg,leg)" bru.... id be surprised if this works at all considering you put instances in that cframe

2 answers

✓ Accepted answer

Why are you putting legs on your CFrame :scream: :scream:

Rock.CFrame = CFrame.new(leg,leg,leg)

should be:

Rock.CFrame = leg.CFrame

Basically replacing Rock.CFrame to leg's CFrame

3 comments

0

why does emoji becomes question marks

0

ok there we go

0

i dont think scripting helpers support emojis

Hello Firend, I wanted to note that I dont think

local Mouse = Player:GetMouse()

Is a thing Use

local Mouse = game:GetService("UserInputService")

and

You can use for Player

local Player = game.Players.LocalPlayer

Note: I am not sure if it will work + I don't know anything about Cframe Just a little Like teleporting a player and parts and that's all

7 comments

0

ya, its a thing, do your proper research before posting your opinions in an answer thats fact-based. SMFH! ! 1. also the player thing is the exact same, no need to unnecessarily point that out!1111!!!11

0

dawg i just need someone to answer this

0

there are different types of cframes

0

You can do a vector3 to achieve what ur tryna do

0

Hey man I joined Lua just 2 weeks ago... don't Think I didn't try to help

0

does this still need answered?

0

No.

This discussion is preserved as it was. New answers, comments, and votes are closed.