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

Why will my script not work? [SIMPLE FOLLOW SCRIPT]

Asked by 8 years ago
while true do
    if script.Parent.Parent.Torso == nil then
        wait(5)
    elseif script.Parent ~= nil and script.Parent.Parent.Torso ~= nil then
        wait(.000000000001)
        script.Parent.CFrame.X = script.Parent.Parent.Torso.CFrame.X + Vector3.new(5,0,0)
        script.Parent.CFrame.Y = script.Parent.Parent.Torso.CFrame.Y + Vector3.new(0,2.5,0)

    end
end

This script is supposed to make the block follow the player (drooling zombie in my case as a demo). And it is meant to not mess with the Z factor due to my levitation script. And Roblox gives me this feedback: PHOTO OF CONSOLE

Thanks, -RadioactiveSherbet

1 answer

Log in to vote
0
Answered by 8 years ago

You cannot directly change components of CFrames:

For example:

Part.CFrame.X = 5 --WOULD NOT WORK

To get around this, you could do this:

Part.CFrame = CFrame.new(
    5, --The X coordinate
    Part.CFrame.Y, --The Y coordinate
    Part.CFrame.Z --The Z coordinate
)

Or, if you wish to keep rotation:

local X,Y,Z = Part.CFrame:toEulerAnglesXYZ() --Gets the rotation

Part.CFrame = CFrame.new(
    5, --The X coordinate
    Part.CFrame.Y, --The Y coordinate
    Part.CFrame.Z --The Z coordinate
) *CFrame.Angles(
    X, --X rotation
    Y, --Y rotation
    Z --Z rotation
)

For more information, go to this link

Ad

Answer this question