So I need help for my npc chat system. In the npc chat system, there is a campart. I want to have two camparts. For example, when I click on the npc, the campart activates, and when I press accept, it switches over to another campart. I want that to happen but the script is only made for one.
-- Local Variables
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Camera = workspace.CurrentCamera
local CamPart = workspace.NPCS.ObbyNPC1.CamPart
local Campart1 = workspace.NPCS.ObbyNPC1.CamPart1
local clickdetector = workspace.NPCS.ObbyNPC1.ClickPart.ClickDetector
local chatline = script.Parent.ChatLine
local accept = script.Parent.ChatLine.Accept
local accept2 = script.Parent.ChatLine.Accept2
local deny = script.Parent.ChatLine.Deny
local billboard = workspace.NPCS.ObbyNPC1.e.BillboardGui
local talksound = script.Parent.TalkSound
local clicksound = script.Parent.ClickSound
local InUse = false
-- Main Script
clickdetector.MouseClick:Connect(function(Player)
if InUse == false then
InUse = true
accept.Visible = false
accept.Visible = false
accept2.Visible = false
accept2.Visible = false
clicksound:Play()
clickdetector.MaxActivationDistance = 0
billboard.Enabled = false
Camera.CameraType = Enum.CameraType.Scriptable
if Camera.CameraType == Enum.CameraType.Scriptable then
chatline:TweenPosition(UDim2.new(0, 0,0.775, 0),"Out", "Quint",1.5)
Camera.CFrame = CamPart.CFrame
wait(0.4)
--- Line number 1.
local text = "Here is my version of a custom NPC."
for i = 1, #text do
chatline.Text = string.sub(text, 1, i)
talksound:Play()
wait(0.05)
end
end
accept.Visible = true
accept.Active = true
end
InUse = false
end)
accept.MouseButton1Click:Connect((function()
if InUse == false then
InUse = true
clicksound:Play()
accept.Visible = false
accept.Visible = false
deny.Active = true
deny.Visible = true
-- Line number 2.
local text = "Simply follow the instructions on how to use it!"
for i = 1, #text do
chatline.Text = string.sub(text, 1, i)
talksound:Play()
wait(0.05)
end
wait(0)
accept2.Visible = true
accept2.Active = true
deny.Active = true
deny.Visible = true
end
InUse = false
end))
accept2.MouseButton1Click:Connect((function()
if InUse == false then
InUse = true
clicksound:Play()
accept.Visible = false
accept.Visible = false
accept2.Visible = false
accept2.Visible = false
deny.Active = true
deny.Visible = true
-- Line number 3.
local text = "Enjoy! -- "
for i = 1, #text do
chatline.Text = string.sub(text, 1, i)
talksound:Play()
wait(0.05)
end
wait(0)
accept2.Visible = false
accept2.Visible = false
deny.Active = true
deny.Visible = true
end
InUse = false
end))
deny.MouseButton1Click:Connect(function(Player)
if InUse == false then
InUse = true
chatline:TweenPosition(UDim2.new(0, 0,1.01, 0),"In","Quint",1)
clicksound:Play()
accept2.Visible = false
accept2.Active = false
deny.Visible = true
deny.Active = true
wait(1)
chatline.Text = " "
Camera.CameraType = Enum.CameraType.Follow
wait(1)
InUse = false
clickdetector.MaxActivationDistance = 10
Camera.CameraType = Enum.CameraType.Follow
billboard.Enabled = true
end
end)
