-
What do you want to achieve?
Im trying to make a system that, when the proximity prompt is activated, and the dialogue starts, it constantly changes the NPC’s face to one of 3 random faces to simulate it talking. -
What is the issue? Include screenshots / videos if possible!
So previously I was using an NPC dialogue system created by a Youtuber called “Bubblx”. After trying to make my previously stated system, the dialogue wouldn’t pop up, and the face never changed. Also, I couldn’t find any errors in the console. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I couldn’t find any solutions/tutorials for a system like what im trying to create.
Unmodified script
local NPC = script.Parent.Parent.Parent
local TalkEvent = game:GetService("ReplicatedStorage").Npc
local Prox = script.Parent
script.Parent.Triggered:Connect(function(plr)
plr.Character.Humanoid.WalkSpeed = 0
plr.Character.Humanoid.JumpHeight = 0
local NpcName = NPC.Name
local M1 = script.Parent.Message1.Value
local M2 = script.Parent.Message2.Value
local M3 = script.Parent.Message3.Value
TalkEvent:FireClient(plr,NpcName, M1, M2, M3,Prox)
end)
TalkEvent.OnServerEvent:Connect(function(plr)
plr.Character.Humanoid.WalkSpeed = 16
plr.Character.Humanoid.JumpHeight = 7.2
plr.Character.Humanoid.JumpPower = 50
end)
My script
local NPC = script.Parent.Parent.Parent
local TalkEvent = game:GetService("ReplicatedStorage").Npc
local Prox = script.Parent
function mouth()
local faceid = math.random(1,3)
local npcface = script.Parent.Parent.Parent.Head.face.Texture
if faceid == 1 then
npcface = 266304601
wait(0.5)
elseif faceid == 2 then
npcface = 266304668
wait(0.5)
elseif faceid == 3 then
npcface = 266304708
wait(0.5)
end
end
script.Parent.Triggered:Connect(function(plr)
plr.Character.Humanoid.WalkSpeed = 0
plr.Character.Humanoid.JumpHeight = 0
local talking = true
local NpcName = NPC.Name
local M1 = script.Parent.Message1.Value
local M2 = script.Parent.Message2.Value
local M3 = script.Parent.Message3.Value
while talking == true do
mouth()
wait(0.5)
end
TalkEvent:FireClient(plr,NpcName, M1, M2, M3,Prox)
talking = false
end)
TalkEvent.OnServerEvent:Connect(function(plr)
plr.Character.Humanoid.WalkSpeed = 16
plr.Character.Humanoid.JumpHeight = 7.2
plr.Character.Humanoid.JumpPower = 50
end)
PS. Im still a bit new to scripting, and this is my first ever post on the devforum.