Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago
Edited 2 years ago

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
0
Sorry if this post is too long, I just need some help, CFrame is hard man :C snipperdiaper 120 — 2y
0
"Rock.CFrame = CFrame.new(leg,leg,leg)" bru.... id be surprised if this works at all considering you put instances in that cframe greatneil80 2647 — 2y

2 answers

Log in to vote
1
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

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

0
why does emoji becomes question marks Xapelize 2658 — 2y
0
ok there we go Xapelize 2658 — 2y
0
i dont think scripting helpers support emojis Xapelize 2658 — 2y
Ad
Log in to vote
1
Answered by 2 years ago

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

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 greatneil80 2647 — 2y
0
dawg i just need someone to answer this snipperdiaper 120 — 2y
0
there are different types of cframes sata5pa3da 286 — 2y
0
You can do a vector3 to achieve what ur tryna do sata5pa3da 286 — 2y
View all comments (3 more)
0
Hey man I joined Lua just 2 weeks ago... don't Think I didn't try to help Hamoodiyt 26 — 2y
0
does this still need answered? allybally12345 40 — 2y
0
No. Hamoodiyt 26 — 2y

Answer this question