Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I get my GUI to work when an NPC touches a block?

Asked by 3 years ago

So you join the game... an npc walks up to you and a gui is supposed to pop up so the text label in it can type to make it look like the npc is talking to you... the only problem is i cant get the gui to activate when the npc is at the required destination. I use pathfinding service on the npc and it walks to an "end position" block i made. How will i go about activating a gui when the npc reaches the end point? would i use a local script? where would i put the script? I tried a remote event but it says its requiring a real characters touch of a block or something to active the remote event. The npc is obviously not a real player so the remote event doesn't activate.

1 answer

Log in to vote
0
Answered by 3 years ago

https://developer.roblox.com/en-us/api-reference/function/Humanoid/Move https://developer.roblox.com/en-us/api-reference/event/Humanoid/MoveToFinished

You can use the Humanoid:Move() function to make the NPC walk towards a part, then use Humanoid.MoveToFinished to detect when they're done, then if it returns true then the gui shows up

This would be used as a script in workspace or serverscriptservice

local gui = -- your gui
local npc = -- your npc
local hum = npc:WaitForChild("Humanoid")
-- assuming you already have moved the humanoid towards the player
hum.MoveToFinished:Connect(function()
    gui.Enabled = true
end)

Hope that helps and sorry if its complicated

0
It works! Thankyou Carlowskey 20 — 3y
0
My other problem was that Roblox studio was acting up. The "player added" event was not working at all, so i think the problem is my computer :P Carlowskey 20 — 3y
Ad

Answer this question