So in the video im showing my game where the player with use the arrows to move the npc character, and the npc is moved by making a waypoint part in the direction of the arrow pressed and the npc moves to it. The only thing is that sometimes the player doesn’t move smoothly and you need to keep pressing the arrows a lot to move the player just a bit instead of just holding them and it moving smoothly in a straight line.
robloxapp-20231028-2118449.wmv (1.8 MB)
1 Like
Where’s the script for this? We can’t help you if we don’t have your script.
1 Like
This Is My Local Script in starterplayer scripts
local input = game:GetService(“UserInputService”)
local play = game.Workspace.PacMan.playing
local player = game.Workspace.PacMan.player
local direction = “”
game.Players.LocalPlayer.PlayerGui:WaitForChild(“Pacman”).TextButton.MouseButton1Click:Connect(function()
play.Value = true
end)
while true do
wait(0.01)
if play.Value == true then
if input:IsKeyDown(Enum.KeyCode.Left) then
print("Moving left")
direction = "Left"
game.ReplicatedStorage.PacMan.move:FireServer(direction)
end
if input:IsKeyDown(Enum.KeyCode.Right) then
print("Moving right")
direction = "Right"
game.ReplicatedStorage.PacMan.move:FireServer(direction)
end
if input:IsKeyDown(Enum.KeyCode.Up) then
print("Moving up")
direction = "Up"
game.ReplicatedStorage.PacMan.move:FireServer(direction)
end
if input:IsKeyDown(Enum.KeyCode.Down) then
print("Moving down")
direction = "Down"
game.ReplicatedStorage.PacMan.move:FireServer(direction)
end
end
end
and here is the server script to move the player from the input (in serverscriptservice)
game.ReplicatedStorage.PacMan.move.OnServerEvent:Connect(function(plr,dir)
local player = game.Workspace.PacMan.player
local hum = player:WaitForChild("Humanoid")
print("got it, now moving")
local waypoint = game.Workspace.PacMan.waypoint:Clone()
waypoint.Parent = game.Workspace.PacMan.waypoints
waypoint.Transparency = 1
waypoint.CanTouch = false
waypoint.CanCollide = false
waypoint.Anchored = true
if dir == "Right" then
print("got it, now moving right")
waypoint.Position = player.PrimaryPart.Position + Vector3.new(-1,0,0)
hum:MoveTo(waypoint.Position)
local scr = game.ReplicatedStorage.PacMan.Script:Clone()
scr.Parent = waypoint
elseif dir == "Left" then
print("got it, now moving left")
waypoint.Position = player.PrimaryPart.Position + Vector3.new(1,0,0)
hum:MoveTo(waypoint.Position)
local scr = game.ReplicatedStorage.PacMan.Script:Clone()
scr.Parent = waypoint
elseif dir == "Up" then
print("got it, now moving up")
waypoint.Position = player.PrimaryPart.Position + Vector3.new(0,0,1)
hum:MoveTo(waypoint.Position)
local scr = game.ReplicatedStorage.PacMan.Script:Clone()
scr.Parent = waypoint
elseif dir == "Down" then
print("got it, now moving down")
waypoint.Position = player.PrimaryPart.Position + Vector3.new(0,0,-1)
hum:MoveTo(waypoint.Position)
local scr = game.ReplicatedStorage.PacMan.Script:Clone()
scr.Parent = waypoint
end
end)