Hello! I made a cutscene script, that was supposed to be working fine. Absolutely no errors, yet I get no results.
Here is some footage of the script ‘not working’:
Some things in my script/stuff that may be the reason to this:
Folder-kept cameras
Using server script and not local script
Messed up on a small bit of code
Can someone check my script to see what I did wrong?
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0 ,false, 0)
local triggerEvent = game.ReplicatedStorage:WaitForChild("Cutscene")
local cameraStrg = game.Workspace.CameraStorage
local bar1 = script.Parent.Bar1
local bar2 = script.Parent.Bar2
bar1.Position = UDim2.new(0,0, 0,0)
bar2.Position = UDim2.new(0,0, 0.5,0)
local gui = script.Parent
local dialog = gui.Text.Dialogue
local function Tween(Object, Value)
local tween = TweenService:Create(Object, tweenInfo, {TextTransparency = Value})
tween:Play()
end
local function Tween2(Object, Value)
local tween = TweenService:Create(Object, tweenInfo, {TextStrokeTransparency = Value})
tween:Play()
end
local camera = workspace.CurrentCamera
local config = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local camTween = TweenService:Create(camera, config, {CFrame = cameraStrg.Cam2.CFrame} )
local function typeMessage(txt, typeTime)
for i=1, #txt do
dialog.Text = string.sub(txt, 1, i)
wait(typeTime / #txt)
end
end
triggerEvent.OnServerEvent:Connect(function()
camera.CameraSubject = cameraStrg.Cam1
camera.CFrame = cameraStrg.Cam1.CFrame
camera.FieldOfView = 80
camTween:Play()
typeMessage("Text here", 2)
camTween.Completed:Wait()
-- wait()
-- end of cutscene
camera.CameraType = Enum.CameraType.Custom
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
camera.CameraSubject = humanoid
gui.Enabled = false
end)
Thank you in advance, and I will be waiting for a response!
Change it to a local script, parent the script to StarterPlayerScripts, and the following will be your new script:
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0 ,false, 0)
local triggerEvent = game.ReplicatedStorage:WaitForChild("Cutscene")
local cameraStrg = game.Workspace.CameraStorage
local bar1 = script.Parent.Bar1
local bar2 = script.Parent.Bar2
bar1.Position = UDim2.new(0,0, 0,0)
bar2.Position = UDim2.new(0,0, 0.5,0)
local gui = script.Parent
local dialog = gui.Text.Dialogue
local function Tween(Object, Value)
local tween = TweenService:Create(Object, tweenInfo, {TextTransparency = Value})
tween:Play()
end
local function Tween2(Object, Value)
local tween = TweenService:Create(Object, tweenInfo, {TextStrokeTransparency = Value})
tween:Play()
end
local camera = workspace.CurrentCamera
local config = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local camTween = TweenService:Create(camera, config, {CFrame = cameraStrg.Cam2.CFrame} )
local function typeMessage(txt, typeTime)
for i=1, #txt do
dialog.Text = string.sub(txt, 1, i)
wait(typeTime / #txt)
end
end
triggerEvent.OnClientEvent:Connect(function()
camera.CameraSubject = cameraStrg.Cam1
camera.CFrame = cameraStrg.Cam1.CFrame
camera.FieldOfView = 80
camTween:Play()
typeMessage("Text here", 2)
camTween.Completed:Wait()
-- wait()
-- end of cutscene
camera.CameraType = Enum.CameraType.Custom
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
camera.CameraSubject = humanoid
gui.Enabled = false
end)
This should work, unless I’m missing something about workspace…
I think I know the solution, but idk how to properly code it. Basically, when the ServerEvent happens, it duplicates the script to everyone. Can someone help me with the duplication script?
I actually just found out the solution, I basically just made it so that when you activate something (touch, prompt, etc.) then it’ll make a script I made in ServerScriptStorage or smth like that, and activate the RemoteEvent via FireAllClients(). In the local script for the guicustscene, I just put OnClientEvent, and it works. Although, thanks for the help everyone!