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

I want to make a value always equal to the torso's position?

He is my code (Yes, the parenting is correct)

Torso = script.Parent.Parent.Parent.Parent.Torso.Position

Torso.Changed:connect(function() -- Error, changed is not a valid member of
	script.Parent.Value = CFrame(Torso)
end)

3 answers

✓ Accepted answer

Position is a Vector3 class and not a game object, so it does not have events.

If you want something that always knows what the Torso's position is, use the Torso, and access its Position.

To fix this, you simply need to get the position correctly. Your problem is that you're trying to set the CFrame of the Value, which doesn't exist. Also, you need to just use the Torso changing to find if it has moved. We can do this by using the Changed event, and finding the property that changed.


We'll fix it like so:

Torso = script.Parent.Parent.Parent.Parent.Torso

Torso.Changed:connect(function(Property) -- Error, changed is not a valid member of
	if Property=="Position" then
		script.Parent.Value = Torso.Position
	end
end)

Just a couple simple mistakes you made, that's all.


Anyways, if you have any further problems/questions, please leave a comment below, and I'll see what I can do. Hope I helped :P

####-Dyler3

4 comments

0

On line 1 you are already doing Position, so on line 4 you are doing Torso.Position.Position?

1

No, I updated it. I already caught that. Thanks for pointing it out though

0

Doesn't work, sorry

1

Where is the script located?

How about this:

local torso = script.Parent.Parent.Parent.Parent.Torso
local posVal = script.PositionValue (Vector3 value)

while true do
	wait()
	if torso.Position ~= posVal.Value then
		posVal.Value = torso.Position
	end
end

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