All subjects concerning the script: -a screenGUI (the dialog) -a folder called "NPCS" that inside we have the caterpillar (my npc). -a part called "CameraPart" that should frame the caterpillar. -a modulescript inside my npc.
ok so , i'm doing a game where i make speak a caterpillar . but , i want that the camera to became scriptable , so can frame the caterpillar. then when the dialog ends , i want the camera to became custom again. but doesn't works. there is my local script (StarterGUI>ScreenGUI>LocalScript) :
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local isinrageof = nil
local ischatting = false
local line = 1
local istalking = false
local dialouges = nil
local function onInputBegan(input,gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
local keyPressed = input.KeyCode
if keyPressed == Enum.KeyCode.E then
if isinrageof ~= nil and not istalking then
if ischatting == false then
line = 1
ischatting = true
dialouges = require(isinrageof.Lines)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharcterAdded:wait()
local Camera = workspace.CurrentCamera
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.CameraPart.CFrame?
Character.Humanoid.WalkSpeed = 0
Character.Humanoid.JumpPower = 0
script.Parent.DialougeHolder.Dialouge.Text = ""
script.Parent.DialougeHolder:TweenPosition(UDim2.new(.5,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Back,.5,true)
wait(.5)
local CurLine = dialouges[line]
istalking = true
for i = 1,#CurLine[1] do
script.Parent.DialougeHolder.Dialouge.Text = string.sub(CurLine[1],0,i)
wait(CurLine[2])
end
if CurLine[3] then
CurLine[3]()
end
istalking = false
line = line +1
else
local CurLine = dialouges[line]
if line > #dialouges then
script.Parent.DialougeHolder:TweenPosition(UDim2.new(.5,0,1.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Back,.5,true)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharcterAdded:wait()
local Camera = workspace.CurrentCamera
repeat wait()
Camera.CameraType = Enum.CameraType.Custom
Character.Humanoid.WalkSpeed = 16
Character.Humanoid.JumpPower = 50
dialouges = nil
ischatting = false
else
local CurLine = dialouges[line]
istalking = true
for i = 1,#CurLine[1] do
script.Parent.DialougeHolder.Dialouge.Text = string.sub(CurLine[1],0,i)
wait(CurLine[2])
end
if CurLine[3] then
CurLine[3]()
end
istalking = false
line = line +1
end
end
end
end
end
end
UserInputService.InputBegan:connect(onInputBegan)
while true do
wait()
if ischatting == false then
isinrageof = nil
for i,v in pairs(workspace.NPCS:GetChildren()) do
if(Character.HumanoidRootPart.Position-v.HumanoidRootPart.Position).magnitude <= 5 then
isinrageof = v
end
end
end
end
and there is the ModuleScript , Called "Lines":
local NPCLines = {
{"Hello traveller. [E]",.05,nil},
{"We're in a place, where everything is possible. [E]",.05,nil},
{"There's only one rule. [E]",.05,nil},
{"Don't dream. [E]",.05,nil},
{"It's the only thing that you really need to escape from. [E]",.05,nil},
{"Please... [E]",.05,function() warn("") end},
}
return NPCLines
nothing works . please help.
