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

How do I move a model to a different position?

I am trying to make it so all of the floors move out of ReplicatedStorage, into the Workspace, and moves it's position. When I run this code, everything works with no errors, except that the position doesn't change. The floors are models in a folder in ReplicatedStorage.

local floor1pos = Vector3.new(1.6, 153.3, -34.4)
local floor2pos = Vector3.new(1.6, 125.3, -34.4)

function NewTower()
	local Floor1 = floors[math.random(1, #floors)]:Clone()
	Floor1.PrimaryPart = tower.Platforms.Platform1
	Floor1:MoveTo(floor1pos)
	Floor1.Parent = workspace

	local Floor2 = floors[math.random(1, #floors)]:Clone()
	Floor2.PrimaryPart = tower.Platforms.Platform2
	Floor2:MoveTo(floor2pos)
	Floor2.Parent = workspace
end

NewTower()

I don't get any errors. It moves the floors to their original position, not the changed one.

4 comments

0

maybe try doing Floor1.PrimaryPart:MoveTo()? im too lazy to go into studio so its just a suggestion

0

That doesn't work because the MoveTo() function can only be used on models.

0

do some debugging. put a print() line in between every piece of code and have each one print something different, this is a working alternative way of finding errors in script if the script doesnt output its own errors. If one of the print() lines dont print then the code after it wont run depending on the way your code is

0

I tried that and it printed everything. But the model, Floor1, doesn't move positions.

1 answer

Firstly, Click your Model on the Explorer and on the Properties PrimaryPart, then Click one of ur Floors on the Explorer.

To Move them, just do this on your Script


Floor1:SetPrimaryPartCFrame(CFrame.New(?, ?, ?)

3 comments

0

You're missing a closing parenthesis.

0

22:22:25.317 - ServerScriptService.GameLogic:20: attempt to call a nil value

0

I fixed the error, although it only moves the primary part

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