Problem: I want these six parts to form a cube but I do not know how to rotate and from what I gather from videos you need to while loop it to rotate? I don't know why that would be a necessity, nonetheless this is my last resort. Anyone mind helping me, somewhere it my code, by pinpointing where the problem is or what is to be exact and give an example? My code is pretty repetitive so.
--Ignore if it is local or server as the game I use this script on merges the two into one as filtering enabled is not on so
Code:
game:GetService("UserInputService").InputBegan:Connect(function(key, proc)
if key.KeyCode == Enum.KeyCode.C then
if proc == true then
else
print("Barrier")
local part1 = Instance.new("Part")
part1.Name = "Wall1"
part1.BrickColor = BrickColor.new("Electric blue")
part1.Material = "Glass"
part1.CanCollide = false
part1.Parent = model:WaitForChild("Head")
part1.BottomSurface = "Smooth"
part1.TopSurface = "Smooth"
part1.Transparency = 0.4
part1.Reflectance = 0.3
part1.Size = Vector3.new(20,20,5)
part1.Anchored = true
part1.CFrame = model:WaitForChild("Torso").CFrame:toWorldSpace(CFrame.new(0,7,-6))
local part2 = Instance.new("Part")
part2.Name = "Wall2"
part2.BrickColor = BrickColor.new("Electric blue")
part2.Material = "Glass"
part2.CanCollide = false
part2.Parent = model:WaitForChild("Head")
part2.BottomSurface = "Smooth"
part2.TopSurface = "Smooth"
part2.Transparency = 0.4
part2.Reflectance = 0.3
part2.Size = Vector3.new(20,20,5)
part2.Anchored = true
part2.CFrame = model:WaitForChild("Torso").CFrame:toWorldSpace(CFrame.new(0,7,6))
local part3 = Instance.new("Part")
part3.Name = "Wall3"
part3.BrickColor = BrickColor.new("Electric blue")
part3.Material = "Glass"
part3.CanCollide = false
part3.Parent = model:WaitForChild("Head")
part3.BottomSurface = "Smooth"
part3.TopSurface = "Smooth"
part3.Transparency = 0.4
part3.Reflectance = 0.3
part3.Size = Vector3.new(20,20,5)
part3.Anchored = true
part3.CFrame = CFrame.new(part3.Position, Vector3.new(0,90,0))
part3.CFrame = model:WaitForChild("Torso").CFrame:toWorldSpace(CFrame.new(3,0,-6))
local part4 = Instance.new("Part")
part4.Name = "Wall4"
part4.BrickColor = BrickColor.new("Electric blue")
part4.Material = "Glass"
part4.CanCollide = false
part4.Parent = model:WaitForChild("Head")
part4.BottomSurface = "Smooth"
part4.TopSurface = "Smooth"
part4.Transparency = 0.4
part4.Reflectance = 0.3
part4.Size = Vector3.new(20,20,5)
part4.Anchored = true
part4.CFrame = CFrame.new(part3.Position, Vector3.new(0,90,0))
part4.CFrame = model:WaitForChild("Torso").CFrame:toWorldSpace(CFrame.new(3,7,6))
local part5 = Instance.new("Part")
part5.Name = "Wall5"
part5.BrickColor = BrickColor.new("Electric blue")
part5.Material = "Glass"
part5.CanCollide = false
part5.Parent = model:WaitForChild("Head")
part5.BottomSurface = "Smooth"
part5.TopSurface = "Smooth"
part5.Transparency = 0.4
part5.Reflectance = 0.3
part5.Size = Vector3.new(20,20,5)
part5.Anchored = true
part5.CFrame = CFrame.new(part3.Position) * CFrame.Angles(-90,0,0)
part5.CFrame = model:WaitForChild("Torso").CFrame:toWorldSpace(CFrame.new(0,8,0))
local part6 = Instance.new("Part")
part6.Name = "Wall6"
part6.BrickColor = BrickColor.new("Electric blue")
part6.Material = "Glass"
part6.CanCollide = false
part6.Parent = model:WaitForChild("Head")
part6.BottomSurface = "Smooth"
part6.TopSurface = "Smooth"
part6.Transparency = 0.4
part6.Reflectance = 0.3
part6.Size = Vector3.new(20,20,5)
part6.Anchored = true
part6.CFrame = CFrame.new(part3.Position, Vector3.new(-90,0,0))
part6.CFrame = model:WaitForChild("Torso").CFrame:toWorldSpace(CFrame.new(0,8,0))
end
end
end)

1 comment
Thanks, after reading this I understand a lot more when dealing with rotating parts. I also thank you for going into such great detail, it really helped ;3.