Help with tween

local ZonePosDictionary = {
	"112.688, -0.865, -124.757", --1
	"59.334, -0.865, -93.981", --2 
	"2.591, -0.865, -156.049", --3
	"44.41, -0.865, 183.104", --4
	"-112.062, -0.865, -141.405", --5
	"-179.031, -0.865, -93.981", --6
	"132.004, -0.865, 36.895", --7
	"91.03, -0.865, 141.343", --8
	"-22.502, -0.865, 149.6", --9
	"-112.062, -0.865, 106.099", --10
	"-137.744, -0.865, 149.6", --11
	"-199.564, -0.865, 182.16" --12
}

	local ZonePos = ZonePosDictionary[math.random(1,12)]
		ClonedZone.Position = Vector3.new(ZonePos)

How do i get the ClonedZone.Position = Vector3.new(ZonePos)
to work? it stays in the same place each time

1 Like

[i removed parts of the script]

2 Likes

All your code currently displayed does is select a position among an array and then changes the position of a cloned object. Is that cloned object ever used or inserted in the world? Does that code snippet execute at all?

1 Like

That is not how you store vectors. You can just have an array with Vector3.new(). By storing it in strings you have to have another function that converts the string to the Vector3 which is just more work.

1 Like

It’s not working because everything is a string (I will add a code later, just trying to figure out how to code it, but i think you should use tonumber())

I removed parts of the code as they aren’t necessary

1 Like

Okay thanks for the help, i will try this

1 Like

Ok, maybe this should work

local ZonePosDictionary = {
	"112.688, -0.865, -124.757", --1
	"59.334, -0.865, -93.981", --2 
	"2.591, -0.865, -156.049", --3
	"44.41, -0.865, 183.104", --4
	"-112.062, -0.865, -141.405", --5
	"-179.031, -0.865, -93.981", --6
	"132.004, -0.865, 36.895", --7
	"91.03, -0.865, 141.343", --8
	"-22.502, -0.865, 149.6", --9
	"-112.062, -0.865, 106.099", --10
	"-137.744, -0.865, 149.6", --11
	"-199.564, -0.865, 182.16" --12
}
local RndNumber = math.random(1,12)
local ZonePos = tonumber(ZonePosDictionary[RndNumber])
print(ZonePos)
ClonedZone.Position = Vector3.new(ZonePos)
1 Like

Just put the values inside Vector3.new() Args. Such as:
Vector3.new(112.688, -0.865, -124.757),

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.