Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I move a model to a different position?

Asked by 3 years ago

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.

0
maybe try doing Floor1.PrimaryPart:MoveTo()? im too lazy to go into studio so its just a suggestion AlexanderYar 788 — 3y
0
That doesn't work because the MoveTo() function can only be used on models. soccerstardance251 29 — 3y
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 AlexanderYar 788 — 3y
0
I tried that and it printed everything. But the model, Floor1, doesn't move positions. soccerstardance251 29 — 3y

1 answer

Log in to vote
0
Answered by
Borrahh 265 Moderation Voter
3 years ago
Edited 3 years ago

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(?, ?, ?)
0
You're missing a closing parenthesis. Ziffixture 6913 — 3y
0
22:22:25.317 - ServerScriptService.GameLogic:20: attempt to call a nil value soccerstardance251 29 — 3y
0
I fixed the error, although it only moves the primary part soccerstardance251 29 — 3y
Ad

Answer this question