Creating a cutscene using remote event

You can write your topic however you want, but you need to answer these questions:

  1. **What do you want to achieve?**Trying to fire an event to trigger a cutscene, but nothing seems to be happening. No errors output

  2. What is the issue? Include screenshots / videos if possible!


  3. What solutions have you tried so far? I did, but I can’t seem to find the solution.

-- The server script server side (script)
local player = game:GetService("Players")
local event = game.ReplicatedStorage.Cutscene1
local order = 0

player.PlayerAdded:Connect(function(plr)
	print(plr," joined!")
	
	local Textlabel = plr.PlayerGui:WaitForChild("ScreenGui").Frame.TextLabel
	Textlabel.Text = "3"
	order = "1"
	event:FireClient(plr,order)
	print("fired")
	wait(3)
	Textlabel.Text = "2"
	wait(3)
	Textlabel.Text = "1"
	wait(3)
end)
-- The cutscene side (local script)
local event = game.ReplicatedStorage.Cutscene1
local tweenservice = game:GetService("TweenService")
local cams = workspace.cams

local function Cutscene(order)
	print(order)
	print("receive")
	workspace.Camera.CameraType = Enum.CameraType.Scriptable
	TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
	if order == 1 then
		print("1")
		local tween = tweenservice:Create(cams.c1,TweenInfo,cams.c2)
		tween:Play()
		workspace.Camera.CameraType = Enum.CameraType.Custom
	else
		print("error")
	end
end

event.OnClientEvent:Connect(Cutscene)
1 Like

Your local script cannot run in the workspace. Try moving it to StarterPlayerScripts

1 Like

It worked. but now it prints “1”, then “error”.

--changed script
local event = game.ReplicatedStorage.Cutscene1
local tweenservice = game:GetService("TweenService")
local cams = workspace.cams

local function cutscene(order)
	print(order)
	workspace.Camera.CameraType = Enum.CameraType.Scriptable
	TweenInfo.new(3,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
	if order == 1 then
		print("order1")
		local tween = tweenservice:Create(cams.c1,TweenInfo,cams.c2)
		tween:Play()
		workspace.Camera.CameraType = Enum.CameraType.Custom
	else
		print("error")
	end
end

event.OnClientEvent:Connect(cutscene)

Try this script. I made the code wait a bit before trying to access anything.

--changed script
game:GetService("Players").LocalPlayer.CharacterAppearanceLoaded:Wait()
local event = game.ReplicatedStorage.Cutscene1
local tweenservice = game:GetService("TweenService")
local cams = workspace.cams

local function cutscene(order)
	order = tonumber(order)
	workspace.Camera.CameraType = Enum.CameraType.Scriptable
	TweenInfo.new(3,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
	if order == 1 then
		print("order1")
		local tween = tweenservice:Create(cams.c1,TweenInfo,cams.c2)
		tween:Play()
		workspace.Camera.CameraType = Enum.CameraType.Custom
	else
		print("error")
	end
end

event.OnClientEvent:Connect(cutscene)
1 Like

try,

if tonumber(order) == 1 then

if that doesn’t work, I have no idea whats wrong.

1 Like

1- Use workspace.CurrentCamera

2- After the camera line you only declared a TweenInfo, the code doesn’t know what to do with that info. I suggest looking at examples on tween service documentation to understand it better. You need to provide an object, target and an info, and you can play the tween after that

3- Use WaitForChild in the client
game.ReplicatedStorage:WaitForChild
workspace:WaitForChild

“1” and 1 are different things as far as I am aware.


This is one of the ways to fix it.


Another is to change
order = "1"
to
order = 1

1 Like

I changed the script a bit, it printed out “Unable to cast to Dictionary”

--changed script
local event = game.ReplicatedStorage:WaitForChild("Cutscene1")
local tweenservice = game:GetService("TweenService")
local cams = workspace:WaitForChild("cams")
-- cams
local cam1 = cams:WaitForChild("c1")
local cam2 = cams:WaitForChild("c2")

local function cutscene(order)
	workspace.Camera.CameraType = Enum.CameraType.Scriptable
	TweenInfo.new(3,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
	if order == 1 then
		print("order1")
		local tween = tweenservice:Create(cam1,TweenInfo,Vector3.new(-5.955, 5.15, 20.29)) --  Unable to cast to Dictionary
		tween:Play()
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	else
		print("error")
	end
end

event.OnClientEvent:Connect(cutscene)

in the print error where it says the dictionary error, on the right of the text, does it say which line the error is from

You can’t do that.
You must put properties in a table.

For example, if I wanted to tween the position of some stairs, I would do:

local tween = tweenservice:Create(stairs,TweenInfo,{Position = Vector3.new(whatever)})
tween:Play()
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.