yeah im trying to move this object however it wont move please help me
while wait() do
local a = 0
while wait(0.1) do
script.Parent.Position.X = script.Parent.Position.X + 1
local a = a + 1
if a == 26 then
break
end
local a = 0
while wait(0.1) do
script.Parent.Position.X = script.Parent.Position.X - 1
local a = a + 1
if a == 26 then
break
end
end
end
end
You canβt assign to ββxββ, here is a working code:
while wait() do
local a = 0
while wait(0.1) do
script.Parent.Position = script.Parent.Position + Vector3.new(1, 0, 0)
local a = a + 1
if a == 26 then
break
end
local a = 0
while wait(0.1) do
script.Parent.Position = script.Parent.Position - Vector3.new(1, 0, 0)
local a = a + 1
if a == 26 then
break
end
end
end
end
Instead of doing a while loop and counting up, simply use a for loop.
while task.wait() do
for a = 1,26,1 do
task.wait(0.1)
script.Parent.Position = script.Parent.Position + Vector3.new(1, 0, 0)
end
for a = 1,26,1 do
task.wait(0.1)
script.Parent.Position = script.Parent.Position + Vector3.new(-1, 0, 0)
end
end
Also, if you want to make it simpler. You can use compound assignments. Such as, +=
You can find the different assignments here