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

Position is not a valid member,what?

Asked by 9 years ago

So I found this script that has global functions in it and I decided to try it out in the output but I got an error saying:

Position is not a valid member

20:44:29.329 - Script 'Workspace.PartTweening', Line 2 - field TweenPosition

20:44:29.329 - Script '_G.TweenPosition(Workspace.Part.Position,Workspace.Part1.CF', Line 1

20:44:29.330 - Stack End

Script with global tables:

_G.TweenPosition = function(part, goal, t)
    local start = part.Position
    local increment = wait() / t
    local x, y, z = part.CFrame:toEulerAnglesXYZ()
    for i = increment, 1, increment do
        wait()
        part.CFrame = (CFrame.new(goal,i) + start:Lerp(goal, i)) * CFrame.Angles(x, y, z)
    end
    part.CFrame = (CFrame.new() + goal) * CFrame.Angles(x, y, z)
end

_G.TweenAngles = function(part, goal, t)
    local start = Vector3.new(part.CFrame:toEulerAnglesXYZ())
    local increment = wait() / t
    for i = increment, 1, increment do
        wait()
        local lerped = start:Lerp(goal, i)
        part.CFrame = CFrame.new(part.Position) * CFrame.Angles(lerped.X, lerped.Y, lerped.Z)
    end
end

_G.TweenPositionAndAngles = function(part, goalP, goalA, t)
    local startP = part.Position
    local startA = Vector3.new(part.CFrame:toEulerAnglesXYZ())
    local increment = wait() / t
    for i = increment, 1, increment do
        wait()
        local lerped = startA:Lerp(goalA, i)
        part.CFrame = (CFrame.new() + startP:Lerp(goalP, i)) * CFrame.Angles(lerped.X, lerped.Y, lerped.Z)
    end
    part.CFrame = (CFrame.new() + goalP) * CFrame.Angles(goalA.X, goalA.Y, goalA.Z)
end
--Blockoo

What I put in the output:

_G.TweenPosition(Workspace.Part.Position,Workspace.Part1.CFrame,1)

How would I fix this error in the script it out in the output?

1 answer

Log in to vote
2
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago

You're passing in the position as the first argument:

_G.TweenPosition(Workspace.Part.Position,Workspace.Part1.CFrame,1)

But your _G.TweenPosition function takes a part as the first argument.

_G.TweenPosition = function(part, goal, t)
...

You should be passing in a part like this.

_G.TweenPosition(Workspace.Part,Workspace.Part1.CFrame,1)
0
I got another error when I changed it: Workspace.Script:7: bad argument #1 to 'new' (Vector3 expected, got userdata) kevinnight45 550 — 9y
1
There's no CFrame constructor that takes a CFrame as the first argument, according to the wiki. The problem is here: CFrame.new(goal,i) Merely 2122 — 9y
0
So it's not me,it's the script? kevinnight45 550 — 9y
1
Do you have an example of how the TweenPosition method is supposed to be used? I think the _G.TweenPosition method you're using expects you to pass in a Vector3 position for the second argument instead of a CFrame. Merely 2122 — 9y
View all comments (6 more)
0
No I don't have an example kevinnight45 550 — 9y
0
Ok I fixed it by changing it to a vector3 value like you said:_G.TweenPosition(Workspace.Part,Workspace.Part1.Position,CFrame,1) kevinnight45 550 — 9y
0
But I got another error the "t" argument: Workspace.Script:3: attempt to perform arithmetic on local 't' (a table value) kevinnight45 550 — 9y
0
"t" is suppose to a number right? kevinnight45 550 — 9y
1
Yeah. Merely 2122 — 9y
0
I'll use another script since I couldn't fix that eror,thanks for the help kevinnight45 550 — 9y
Ad

Answer this question