#How can I get a r6 rig to move to a specific location after a remoteevent?

1 messages · Page 1 of 1 (latest)

valid merlin
#

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

steel hearth
#

:moveto

valid merlin
#

and trying to trigger the movement with an event still doesnt work

steel hearth
#

Theres an timeout for it

#

Uh and a moveto.finished event and then u just move to again until it reaches the waypoint

valid merlin
#

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

steel hearth
#

then it doesnt work perfectly fine

valid merlin
#

I... suppose...

steel hearth
#

Didnt understand what your saying

#

Maybe send the script?

valid merlin
#

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)```
steel hearth
#

dont know what half of the script is even doing so delete it

valid merlin
#

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 💀
lavish stirrupBOT
#

studio** You are now Level 6! **studio

valid merlin
#

DONT CRY REACT ME

short gyro
#

Thats not even closecrying

valid merlin
#

listen bro

#

Im well aware

#

My only knowledge here is the java scripting class I took in MIDDLE SCHOOL 7 YEARS AGO

short gyro
steel hearth
#

all the variables are terrible

valid merlin
#

ty 🙏

#

LMAIO

valid merlin
short gyro
steel hearth
#

like i havent seen someone name their variables like that

#

and the code looks messy

valid merlin
#

REF DO SOMETHING

#

THEYRE TEARING ME APART

short gyro
#

Yo I will help when I get on pc

#

I’m on phone, and scripting on phone is just pain

valid merlin
#

thank you king 😭

valid merlin
steel hearth
#

doesnt work like that

#

try learning to script

valid merlin
short gyro
#
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)
steel hearth
#

to get free code

short gyro
short gyro
valid merlin
# steel hearth to get free code

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.

steel hearth
#

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

short gyro
#

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?crying

valid merlin
short gyro
steel hearth
#

whats a local event

short gyro
#

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"

steel hearth
#

btw

valid merlin
#

oh I'm well aware thats another reason I have no idea what I'm doing lol

short gyro
steel hearth
#

lua

short gyro
#

bro stop ragebaitingcrying

steel hearth
#

i didnt

#

@short gyro

short gyro
toxic elbow
#

man this guy is ragebaiting for sure

short gyro
steel hearth
#

how did i ragebait

valid merlin
#

😭

steel hearth
#

time to learn lua

toxic elbow
#

you are ragebaiting

steel hearth
#

on youtube

steel hearth
toxic elbow
#

you didnt even know what was server/local events

short gyro
#

yeah and u think we dont know that java and lua is the same langauge???

valid merlin
#

bro I KNEW about server and local events

toxic elbow
#

it is this guy

#

st231

valid merlin
#

No yeah I know

steel hearth
toxic elbow
#

bro is telling us to learn lua but he does not even know what is server/local events

valid merlin
#

Im saying I KNEW what they were and I'm meant to be the person who doesnt know anything here

short gyro
toxic elbow
toxic elbow
#

nah okay

steel hearth
#

to make that script

toxic elbow
#

now this is ragebait

#

100%

steel hearth
#

no

#

time to learn lua

#

hahaa

toxic elbow
short gyro
toxic elbow
#

MAYBE

#

that is why

#

he is here

steel hearth
#

no

#

that is ragebait

toxic elbow
#

yea

#

im ragebaiting

#

💀

steel hearth
#

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)

steel hearth
#

probably not

#

i just sent it

gloomy radish
steel hearth
#

why

gloomy radish
#

Already wrote like 30+ useless messages

toxic elbow
steel hearth
#

what?

#

and?

gloomy radish
toxic elbow
steel hearth
#

... you can have it

toxic elbow
#

that is not my point

steel hearth
toxic elbow
#

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

steel hearth
#

what

#

got it

#

so theres the solution to the problem

#

@valid merlin

valid merlin
#

I appreciate you trying to help now but blaze is helping me figure it out in dms 😭 🙏

steel hearth
#

and why not here?

short gyro
steel hearth
#

ok

valid merlin
#

the annotations are definitely chatgpt 😭

steel hearth
#

gnomecode made them actually

valid merlin
#

idk why companies are so confident ai is good at coding honestly

steel hearth
#

they arent

#

its pretty useless

#

ai

valid merlin
#

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

toxic elbow
#

tbh roblox assistant is horrible

short gyro
toxic elbow
#

i think a 6yr old kid can be smarter

valid merlin
#

probably 😭

short gyro
#

dude if u need help with something, you have to ask the stupid ai like 600 times to get it sorta working

steel hearth
#

chatgpt only helps out

#

dont know about any other one

toxic elbow
#

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

short gyro
#

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

valid merlin
#

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

steel hearth
#

but it can code better than you

valid merlin
#

is that why you pretend its your girlfriend?

gloomy radish
#

3 people ragebaiting is insane I bet you all suck at coding

short gyro
steel hearth
#

doesnt sound like my problem

gloomy radish
#

And @toxic elbow

short gyro
valid merlin
#

nah skid is cool i think

steel hearth
#

i think you are ragebaiting

#

@gloomy radish

#

but ok

toxic elbow
#

dani is rage baiting

short gyro
#

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

valid merlin
#

wow thats awesome did you make steal a brainroty

steel hearth
toxic elbow
#

when did i ragebait

steel hearth
#

scroll up

#

arent you playing valorant?

toxic elbow
#

you were arguing about giving free code

#

but then you gave one

steel hearth
#

where is the proof

steel hearth
#

: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

toxic elbow
gloomy radish
#

Jst stop writing pls

steel hearth
#

then how did u know i dont know about server/local events?

#

how did u check it

#

i think i know them

short gyro
short gyro
#

my fault i didnt mean to start the fire again

#

anyways its solved now

steel hearth
short gyro
#

Event.OnServerEvent is still a valid way to detect server events in a server script???

steel hearth
#

u used .onserverevent if thats what u wer referring to

#

ye u said serverevent which doesnt make sense

short gyro
#

yeah it i supposed to be ".OnServerEvent"

#

I said it for reference

short gyro
#

You miss capital letters: "O", "S" or "E".

steel hearth
#

where miss

short gyro
#

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

steel hearth
#

i have been*

gloomy radish
steel hearth
#

in lua theres no services...

short gyro
steel hearth
#

i didnt know it

#

its the luau language