Can't change Model Position

  1. What do you want to achieve? Basically, I just started learning OOP and trying Advanced Module Scripts, I’m trying to make this Animal Model change positions to their expected positions, however this does not work for some reason.

  2. What is the issue?

  • Neon Yellow Part = Animal
  • Gray Part = Expected Position
  1. What solutions have you tried so far? I’ve tried changing from this
if index == "AnimalPosition" and currentAnimal then
		print(value)
		currentAnimal.Torso.Position = value
	end

to this

if index == "AnimalPosition" and currentAnimal then
		print(value)
		currentAnimal.Torso.Position = Vector3.new(value)
	end

but neither works.

Any help would be appreciated

What’s the value?

Is it a Vector3Value.Value? If so, you just do ...Position = Vector3Value.Value

Show the value, please.

Yes, it is a Vector3 value.

Server Script:

local testModule = require(script.Parent.TestModule)
local currentAnimal = nil

amongus = testModule.new("Lion", 100, 3)
spawnAnimal = testModule:spawn(game.ReplicatedStorage.Lion, workspace.SpawnPart.Position)

print(amongus)

for i, v in pairs(amongus) do
	print(i .. ": " .. v)
end

for index, value in pairs(spawnAnimal) do
	if index == "Animal" then
		value:Clone().Parent = workspace.Animals
		currentAnimal = value
	end
	if index == "AnimalPosition" and currentAnimal then
		print(value)
		currentAnimal.Torso.Position = Vector3.new(value)
	end
end

Module:

local Animals = {}
Animals.__index = Animals

print("Loaded AnimalService")

--[[local module = {
	food = "chicken wing",
	otherFood = "hotdog",
	changeFood = function(self, expected)
		self.food = expected
		print("Now ".. expected)
	end
}]]--

function Animals.new(animalName, animalHealth, animalSize)
	local newAnimal = {}
	setmetatable(newAnimal, Animals)
	
	newAnimal.Name = animalName
	newAnimal.Health = animalHealth
	newAnimal.Size = animalSize
	
	return newAnimal
end

function Animals:spawn(animalObject, position)
	local expectedToSpawn = {}
	setmetatable(expectedToSpawn, Animals)
	
	expectedToSpawn.AnimalPosition = position
	expectedToSpawn.Animal = animalObject
	
	return expectedToSpawn
end

--print("Was ".. module.food)

return Animals

try doing
local PositionValue = placeOfValue

currentAnimal.Torso.Position = Vector3.new(PositionValue.Value)

I tried your method on using Vector3Value, Unfortunately it didn’t work.

I think I misunderstood what you said, No I’m not using Vector3Value, but the value is a Vector3.

What is the testModule ModuleScript returning?

The TestModule is the Module you see on the second script, if I do Animals:spawn(animalObject, position) it will return the animalObject we want to spawn and the expected position of the animal (where we want to place the animal)

If you index a specific part of the model and adjust its position/CFrame, it’ll only move that Instance.

In order to move an entire model, you can utilize Model:SetPrimaryPartCFrame(), which will teleport the model by its PrimaryPart to a new location.

I’m aware of that, I tried that once but that didn’t work. (And yes, I did try using CFrame instead of Vector3)

There’s the possibility that the PrimaryPart of the Model was not set – when creating the Animals, ensure that Model.PrimaryPart is not nil.


Otherwise, referring to the original post, are any of the parts being teleported to the new location or is nothing happening at all? Any errors in the Output when you try to adjust its position?

I’d suggest adding print statements inside of the functions and various conditional statements (if you haven’t already) to determine which conditions are being met in addition to different values depending on what happens (e.g. if the condition where the Animal is about to be teleported was met, try printing its Position before & after trying to change it to a new value).

I did add print statements inside the function, no errors, and no parts are teleported. Also, the primary part is not nil, It just won’t change.