A really simple question because I'm super bad at scripting, I'm trying to make an NPC run from one side of a field to another once a remoteevent is called by the player, but I can't get it to work. I have code that properly moves the character, I have code that properly calls and checks for the event, but when I put the two together it just doesnt work. I'll send the script I'm dealing with in a second, but If anyone can help thatd be lovely
#How can I get a r6 rig to move to a specific location after a remoteevent?
1 messages · Page 1 of 1 (latest)
:moveto
The npc just gives up and stops moving like an 8th of the way there 😭
and trying to trigger the movement with an event still doesnt work
Theres an timeout for it
Uh and a moveto.finished event and then u just move to again until it reaches the waypoint
The script works perfectly fine but when I try to add the parameter that it only starts moving after recieving an event it breaks and doesnt move at all
then it doesnt work perfectly fine
I... suppose...
I'm gonna be honest I dont understand 90% of it I copied most of it from doccumentation pages 😭
local racestart = ReplicatedStorage:WaitForChild("Racestart")
local PathfindingService = game:GetService("PathfindingService")
local humanoid = game.Workspace.Helios:WaitForChild("Humanoid")
local model = game.Workspace.Helios
local finishPart = game.Workspace.finishpart
if not model.PrimaryPart then
model.PrimaryPart = model:FindFirstChild("HumanoidRootPart") or model:FindFirstChildWhichIsA("BasePart")
end
local function walkTo(targetPosition)
local path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
AgentJumpHeight = 10,
AgentMaxSlope = 45,
})
path:ComputeAsync(model.PrimaryPart.Position, targetPosition)
local waypoints = path:GetWaypoints()
for _, waypoint in ipairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
local reached = humanoid.MoveToFinished:Wait()
if not reached then
-- retry the same waypoint if failed
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
end
end
walkTo(finishPart.Position)```
dont know what half of the script is even doing so delete it
Ok I tried actually writing my own thing
local racestart = ReplicatedStorage:WaitForChild("Racestart")
local humanoid = game.Workspace.Helios:WaitForChild("Humanoid")
local finishloc = game.Workspace.finishpart.Position
local pos = Vector3.new()
local racing = false
pos = (finishloc)
racestart.OnServerEvent:Connect(function()
racing = true
end)
while racing == true do
humanoid:MoveTo(pos)
task.wait(4)
end
humanoid.MoveToFinished:Connect(function(reached)
if reached then
racing = false
end
end)```
But it doesnt work 💀
** You are now Level 6! **
DONT CRY REACT ME
Thats not even close
listen bro
Im well aware
My only knowledge here is the java scripting class I took in MIDDLE SCHOOL 7 YEARS AGO
Damn, if that was python it would be 10x easier
all the variables are terrible
I'll be sure to email the school board 💀
Wdym there is a while racing == true that will exhaust the script and pos = (finishloc) idk wth, thats just an error
thank you king 😭
the pos = (finishloc) thing is cause I was looking at example scripts, and from what I saw, doing that put the contents of the second variable in the brackets of the first variable but ig thats not how that works at all 😭
chief.... why.. why do you think im here
local RS = game:GetService("ReplicatedStorage")
local Racestart = RS:WaitForChild("Racestart")
local Humanoid = game.Workspace.Helios:WaitForChild("Humanoid")
local FinishLoc = game.Workspace.finishpart.Position
Racestart.OnServerEvent:Connect(function()
Humanoid:MoveTo(FinishLoc)
end)
to get free code
its rly simple, as long as the waitforchild names are the same it would work
we all start somewhere, and asking for help is crucial to learn
thats an assumption you made for yourself. I never asked for free code I asked for advice on why what I was doing wasnt working.
uhh ok
doesnt explain why you didnt solve it then
cuz if u wanted to learn to script u would have done something easier than chat on discord
why u mad bro?
ye ik its free code, but she didnt even ask for code to begin with. The code is like 8 lines long tho
this whole channel is made for "help" is that hard to understand?
Ive been trying to figure out how to get it to work since yesterday man 😔 I actually generally dislike going to discord for help cause I always get clowned on
why is there a serverevent?
beacuse is a server script and it dosent detect localevent???
whats a local event
when the server fires a event to a client it is a "LocalEvent"
but in this case the client send an event to the server making it a "ServerEvent"
java isnt the same as lua
btw
oh I'm well aware thats another reason I have no idea what I'm doing lol
wow I thought all programing language are same omg that is so cool
so why dont you learn it?
lua
bro stop ragebaiting
why do u think she is asking for help then?
bro its okay to ask for help in #1020374354867007528 when u need to learn
man this guy is ragebaiting for sure
fr
how did i ragebait
😭
time to learn lua
you are ragebaiting
on youtube
calm down
you didnt even know what was server/local events
yeah and u think we dont know that java and lua is the same langauge???
bro I KNEW about server and local events
nono im not talking about u
it is this guy
st231
No yeah I know
whats the point
bro is telling us to learn lua but he does not even know what is server/local events
Im saying I KNEW what they were and I'm meant to be the person who doesnt know anything here
crazy, and he is saying that you need to learn😭
ong 😭
then why dont u learn lua?
nah okay
to make that script
i think he is already learning man
fr
thats why u dont be on discord
wasnt funny
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- listen for the humanoid reaching its target
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- start walking
humanoid:MoveTo(targetPoint)
-- execute on a new thread so as to not yield function
task.spawn(function()
while not targetReached do
-- does the humanoid still exist?
if not (humanoid and humanoid.Parent) then
break
end
-- has the target changed?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- refresh the timeout
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- disconnect the connection if it is still connected
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "Destination reached!") or "Failed to reach destination!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)
So did you get it to work?
Stfu already bro yapping all day holy kids
why
Already wrote like 30+ useless messages
so you just gave a free code
Not everyone is going to invest the time to learn lua, just want a simple working code
yea i have no problem with that
... you can have it
that is not my point
u just wrote ragebait hello
but this guy that gave the free code were arguing some moments ago because he thought the guy that opened this post wanted free code
he is ragebaiting
I appreciate you trying to help now but blaze is helping me figure it out in dms 😭 🙏
🤬
and why not here?
chat gpt ahh code, u dont even know difference between server and local
ok
the annotations are definitely chatgpt 😭
gnomecode made them actually
idk why companies are so confident ai is good at coding honestly
I asked that stupid roblox assistant a question on a boolean once a while back and it freaked out and deleted like half of my game
tbh roblox assistant is horrible
fr
i think a 6yr old kid can be smarter
probably 😭
dude if u need help with something, you have to ask the stupid ai like 600 times to get it sorta working
yea you should never copy code from chatgpt
only ask help for it
but still sometimes chatgpt cant even help because he gives outdated things
also chat gpt learns from the internet, so that means like reddit posts and stuff. The thing is, humans are wrong aswell. So you can't guarantee that it is correct
yea
It also doesnt have any functional brain capacity. it can't really think and it doesnt understand what the code is doing or meant to do
but it can code better than you
is that why you pretend its your girlfriend?
3 people ragebaiting is insane I bet you all suck at coding
it aint 3 people its just @steel hearth 
doesnt sound like my problem
And @toxic elbow
when did he ragebait?
nah skid is cool i think
how much u bet?
dani is rage baiting
fr
he dosent have scripter rank even.
ik I am s1 rn, but I got that role a year ago
I been scripting for years and lua a lil over a year
I have made several games fulle myself. Withou ai or toolbox
wow thats awesome did you make steal a brainroty
he ragebaited 2 times
when did i ragebait
huh
where is the proof
you are really good at scripting too
:P
there is only remoteevents in replicated storage
so theres not a local event object
i know remote events can be accessible on both the server and client
i know that
Jst stop writing pls
then how did u know i dont know about server/local events?
how did u check it
i think i know them
u asked me why I used "ServerEvent" in a server script
.
my fault i didnt mean to start the fire again
anyways its solved now
its a remote event
yeah and?
Event.OnServerEvent is still a valid way to detect server events in a server script???
u used .onserverevent if thats what u wer referring to
ye u said serverevent which doesnt make sense
this also is invalid
You miss capital letters: "O", "S" or "E".
where miss
luau?
shut the fuck up
yeah sorry luau, ofc like who tf u think I am bro
everyone says lua, Ik roblox runs on luau, but I program in lua aswell anyways
i have been*
Luau, Lua nobody cares bro its like almost the same
in lua theres no services...
you dumb fuck, it's Roblox studio game engine that has these services