The two examples you gave mean the exact same thing. It’s just that the first example doesn’t work for names with spaces/special characters. Either way works just fine.
Also I tested my own code I realized workspace should be Workspace and works just fine. After that change the code works
local one = game.Workspace.MaponePos
block.Position = game.Workspace.one.Position
would be equivalent to game.Workspace.game.Workspace.MaponePos.Position
What I believe @thetacah meant was that game.Workspace.one.Position is wrong because it is trying to reference an instance named ‘one’ that may not exist, not because it is referencing the Workspace twice.
Woops, I realized I replied to the wrong user. However, the code can be as simple as this :
local Play = true -- // Play The Loop.
local Part1 = workspace.MaponePos -- // Directory of the first part to move to.
local Part2 = workspace.MaptwoPos -- // Directory of the second part to move to.
local MainBlock = workspace.Block -- // Directory of the main part to move.
local Delay = 5 -- // How long to wait in-between changing the position of the MainBlock.
while Play do -- // Loop.
wait(Delay) -- // Wait.
MainBlock.Position = Part1.Position -- // Go To Part1's Position.
wait(Delay) -- // Wait.
MainBlock.Position = Part2.Position -- // Go To Part2's Position.
end -- // End the loop.
This was mostly said by @lcgecko moments ago, but I tried making it a bit easier to understand / read. Was this all of your concern?
I agree that it is the same, but that wasn’t the issue I was referring to. In your first post on this thread it looks like you were saying that something like:
local x = workspace.a.b.c
local y = workspace.x
is the same as:
local y = workspace.workspace.a.b.c
But obviously it isn’t. In the statement y = workspace.x, the ‘x’ is not substituted with ‘a.b.c’. It is just treated like y = workspace["x"] which means it would be referencing something named ‘x’, not the object referenced by ‘a.b.c’
Is this a local script or a server script? If you are running a game instead of playtesting, local scripts don’t run. If those things don’t work, use Vector3 instead:
local block = game.workspace.Block
while true do
wait(5)
block.Position = Vector3.new() -- One position here
wait(5)
block.Position = Vector3.new() -- Two position here
end
But the true error of your code is on how you indexed the code:
local one = game.workspace.MaponePos
local two = game.workspace.MaptwoPos
local block = game.workspace.Block
while true do
wait(5)
block.Position = game.workspace.one.Position -- This means game.workspace.game.workspace.MaponePos.Position
wait(5)
block.Position = game.workspace.two.Position
end
To fix that do this:
local one = game.workspace.MaponePos
local two = game.workspace.MaptwoPos
local block = game.workspace.Block
while true do
wait(5)
block.Position = one.Position
wait(5)
block.Position = two.Position
end
I am using this code that someone said it works with it but its not working
local Play = true – // Play The Loop.
local Part1 = workspace.GameOne – // Directory of the first part to move to.
local Part2 = workspace.GameTwo – // Directory of the second part to move to.
local MainBlock = workspace.Game – // Directory of the main part to move.
local Delay = 5-- // How long to wait in-between changing the position of the MainBlock.
while Play do – // Loop.
wait(Delay) – // Wait.
MainBlock.Position = Part1.Position – // Go To Part1’s Position.
wait(Delay) – // Wait.
MainBlock.Position = Part2.Position – // Go To Part2’s Position.
end – // End the loop.