So I’m working on a game similar to B-Cubed. You may be familiar with this game if you were a Coolmathgames junkie like me. The objective of the game is to reach B starting at A using ‘WASD’. Blocks would fall behind you as you move a specific direction.
Anywho, I’m having trouble deciding what the next step would be. I have the code for detecting what the former part was. MainPart was touching Part1 in the path including (Part1, Part2, Part3), therefore when hitting D to move RIGHT, Part1 would fall and the MainPart would be on top of Part2.
So the question is, how do I code this to work with WASD and to move parts on a designated path where there are multiple directional possibilities?
Here’s what I got so far, it works for declaring what part is touching the MainPart.
ReplicatedStorage:WaitForChild('MovePart').OnServerInvoke = function(x) local Dir = x local Connection = MainPart.Touched:Connect(function() end) for i, v in pairs(MainPart:GetTouchingParts()) do if v:IsA('BasePart') and v.Parent.Name == 'Path' then table.insert(TouchingParts, v) wait() if Connection then Connection:Disconnect() Connection = nil end spawn(function() MainPart.CFrame = CFrame.new((MainPart.CFrame-MainPart.Position)*CFrame.Angles(0,math.pi/2,0) + MainPart.Position) MainPart:MoveTo(FindNextPath(Dir)) for i = 1, 20 do local x = math.random(-100,100)/100 local y = math.random(-100,100)/100 local z = math.random(-100,100)/100 v.CFrame = CFrame.new(x,y,z) wait() v.Anchored = false --table.remove(TouchingParts, v) end end) end end end