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 10 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:

01_G.TweenPosition = function(part, goal, t)
02    local start = part.Position
03    local increment = wait() / t
04    local x, y, z = part.CFrame:toEulerAnglesXYZ()
05    for i = increment, 1, increment do
06        wait()
07        part.CFrame = (CFrame.new(goal,i) + start:Lerp(goal, i)) * CFrame.Angles(x, y, z)
08    end
09    part.CFrame = (CFrame.new() + goal) * CFrame.Angles(x, y, z)
10end
11 
12_G.TweenAngles = function(part, goal, t)
13    local start = Vector3.new(part.CFrame:toEulerAnglesXYZ())
14    local increment = wait() / t
15    for i = increment, 1, increment do
View all 33 lines...

What I put in the output:

1_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
10 years ago

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

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

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

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

You should be passing in a part like this.

1_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 — 10y
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 — 10y
0
So it's not me,it's the script? kevinnight45 550 — 10y
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 — 10y
View all comments (6 more)
0
No I don't have an example kevinnight45 550 — 10y
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 — 10y
0
But I got another error the "t" argument: Workspace.Script:3: attempt to perform arithmetic on local 't' (a table value) kevinnight45 550 — 10y
0
"t" is suppose to a number right? kevinnight45 550 — 10y
1
Yeah. Merely 2122 — 10y
0
I'll use another script since I couldn't fix that eror,thanks for the help kevinnight45 550 — 10y
Ad

Answer this question