Hi, Im making a roblox game, i want so it makes a line of blocks that then it rotates if i enter 90 then it rotate 90 degrees, but it still goes forward, it does rotate tho here is a picture of the block rotation
here is the code:
local num1 = 10
local BlocksX = {}
local lastBlock = nil
local lastModel = nil
local cooldowntable = {}
local function cloneBlock(pos, XorY, color, rotation,parent)
local block = game.ServerStorage.Block:Clone()
block.Parent = workspace
block.Anchored = true
block.BrickColor = color
if parent then
block.Parent = parent
end
block.CFrame = pos
print(block:GetPivot())
lastBlock = block
if XorY == "x" then
table.insert(BlocksX, block)
else
table.insert(BlocksY, block)
end
end
local function createWall(plr,rotateOffset,dependOnPlayer,doRotate)
local sum = 0
local pos
if doRotate == false then
local newPos = Vector3.new(3,0,0)
pos = plr.Character.HumanoidRootPart.CFrame
pos = pos + newPos
else
local newPos = Vector3.new(0,0,-3)
pos = lastBlock.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(rotateOffset),math.rad(-rotateOffset*2),0) + newPos
end
for i = 0,num1,1 do
cloneBlock(pos + Vector3.new(sum,0,0),"x",BrickColor.random(),rotateOffset)
sum += 3
wait(.01)
end
end
game.ReplicatedStorage.FireServer.OnServerEvent:Connect(function(plr)
print("server")
if table.find(cooldowntable,plr) then return end
task.spawn(function()
table.insert(cooldowntable,plr)
wait(1)
for i, v in game.Players:GetPlayers() do
if table.find(cooldowntable,plr) then
table.remove(cooldowntable,i)
end
end
end)
createWall(plr,0,true,false)
createWall(plr,90,false,true)
end)
All help appreciated, Thanks
Edit: I want it to all sides 180 270 360, ty!