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

Position is not a valid member,what?

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

✓ Accepted answer

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)

10 comments

0

I got another error when I changed it: Workspace.Script:7: bad argument #1 to 'new' (Vector3 expected, got userdata)

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)

0

So it's not me,it's the script?

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.

0

No I don't have an example

0

Ok I fixed it by changing it to a vector3 value like you said:_G.TweenPosition(Workspace.Part,Workspace.Part1.Position,CFrame,1)

0

But I got another error the "t" argument: Workspace.Script:3: attempt to perform arithmetic on local 't' (a table value)

0

"t" is suppose to a number right?

1

Yeah.

0

I'll use another script since I couldn't fix that eror,thanks for the help

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