Hello everyone, I am currently working on a “commanding system” with multiple levels. Basically the player can send commands to control their player and then eventually reach the end and move on to the next level. I have commanded my “guy” to go forward, then right and then forward again (to pass the level)
However I am stuck on a few points:
- When sending the RemoteEvent to command the player to walk, I want it to stop when an obstacle is in the way (for example the wall in the middle or the wall on the right after the “right” command is done (which should then move on to forward walking again)
What I tried:
- I have written down the Vectors for each direction (for example “Up/Straight” being
1, 0, 0
), which would not be good because every level has different orientations and so Right may be straight walking or the other way around in some levels.
local vectorTables = {
["Up"] = Vector3.new(1, 0, 0),
["Down"] = Vector3.new(-1, 0, 0),
["Right"] = Vector3.new(0, 1, 0),
["Left"] = Vector3.new(0, -1, 0)
}
Basically, the main issue being that I don’t know how to make the player walk until there is an obstacle in the way, also taking in the orientation.
I am sending over a table to the server which is the directions, so {"Up", "Right", "Up"}
in this case which should then be processed to make the player walk server-side and check the win-condition if walked over a yellow neon field.
This is what I’ve tried so far:
function module.executeOperation(player, informationTable)
local data = Data.getData(player)
if not informationTable or typeof(informationTable) ~= "table" then return end
if not data then return end
if not data.InGame then return end
local levelFolder = Levels:FindFirstChild(data.SelectedLevel)
if #informationTable ~= levelFolder:GetAttribute("Moves") then return end
local vectorTables = {
["Up"] = Vector3.new(-1, 0, 0),
["Down"] = Vector3.new(1, 0, 0),
["Right"] = Vector3.new(0, -1, 0),
["Left"] = Vector3.new(0, 1, 0)
}
local character = player.Character
local hrp = character.PrimaryPart
local humanoid = character:WaitForChild("Humanoid")
for index, direction in informationTable do
end
-- now check location if on winner pad and move on
end