Works in studio, but doesn't work in game

I wrote a local script for the cutscene, and I noticed that the script only works in the studio, but not in the game itself, and there are also no errors in the output

Roblox Studio:

robloxapp-20240805-1750498.wmv (653.4 KB)

Game:

robloxapp-20240805-1752264.wmv (966.3 KB)

And here is my code:

local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait()

--services
local ts = game:GetService("TweenService")
local rs = game:GetService("ReplicatedStorage")
local gameInfo = require(rs:WaitForChild("Server"):WaitForChild("Modules"):WaitForChild("GameInfo"))

--remotes
local startRemote = rs:WaitForChild("StartCS")
local endRemote = rs:WaitForChild("CSEnded")

--assets
local base = workspace:WaitForChild("CutsceneCar").PrimaryPart
local door = workspace:WaitForChild("House"):WaitForChild("Floor1"):WaitForChild("Door")

--cam
local cam = workspace.CurrentCamera
local camFolder = workspace:WaitForChild("CutsceneCameraParts")

--tweens
local ti = TweenInfo.new(2, Enum.EasingStyle.Circular, Enum.EasingDirection.Out, 0, false, 0)
local startti = TweenInfo.new(0.00001, Enum.EasingStyle.Circular, Enum.EasingDirection.Out, 0, false, 0)
local csti = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local cs2ti = TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local dad1ti = TweenInfo.new(3, Enum.EasingStyle.Circular, Enum.EasingDirection.Out, 0, false, 0)
local kid2ti = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local kid1ti = TweenInfo.new(1.5, Enum.EasingStyle.Circular, Enum.EasingDirection.Out, 0, false, 0)

--animations
local walkAnim = script:WaitForChild("dadWalk")
local idleAnim = script:WaitForChild("Idle")

--faces
local faceFolder = rs:WaitForChild("Assets"):WaitForChild("Faces")

local dadFace = faceFolder:WaitForChild("dadFace")
local kidFace = faceFolder:WaitForChild("kidFace")
local openFace = faceFolder:WaitForChild("openFace")
local teethFace = faceFolder:WaitForChild("teethFace")

--sounds
local carGroup = game:GetService("SoundService"):WaitForChild("Car")
local dadVoices = game:GetService("SoundService"):WaitForChild("DadVoices"):WaitForChild("CutScene")

function endCS()
	cam.FieldOfView = 60
	gameInfo.GameActive = true
	endRemote:FireServer(true)
end

function CloneMe()
	char.Archivable = true
	local clone = char:Clone()
	char.Archivable = false
	return clone
end

local function dadFaceAnim(face)
	face.Texture = dadFace.Texture
	task.wait(0.15)
	face.Texture = openFace.Texture
	task.wait(0.15)
	face.Texture = teethFace.Texture
	task.wait(0.15)
	face.Texture = dadFace.Texture
	task.wait(0.15)
	face.Texture = openFace.Texture
	task.wait(0.15)
	face.Texture = teethFace.Texture
	task.wait(0.15)
	face.Texture = dadFace.Texture
end

local function startCS()
	cam.CameraType = Enum.CameraType.Scriptable
	task.wait(5)
	
	local target = base.CFrame + Vector3.new(0, 0, 0)
	local targetstart = base.CFrame - Vector3.new(0, 1, -30)
	
	cam.CFrame = camFolder:WaitForChild("Cam1").CFrame
	ts:Create(base, startti, {CFrame = targetstart}):Play()

	task.wait(1)
	
	carGroup:WaitForChild("CarStop"):Play()

	ts:Create(cam, csti, {CFrame = camFolder:WaitForChild("Cam2").CFrame}):Play()

	task.wait(2)

	ts:Create(base, ti, {CFrame = target}):Play()

	task.wait(3)

	cam.CFrame = camFolder:WaitForChild("Cam3").CFrame
	ts:Create(cam, cs2ti, {CFrame = camFolder:WaitForChild("Cam4").CFrame}):Play()

	local charClone = CloneMe()
	local cloneHum = charClone:WaitForChild("Humanoid")

	local kid = rs:WaitForChild("Assets"):WaitForChild("Characters"):WaitForChild("Kid"):WaitForChild("Eric"):Clone()
	local kidHum = kid:WaitForChild("Humanoid")

	local charFace = charClone:WaitForChild("Head"):WaitForChild("face")
	local kidFace = kid:WaitForChild("Head"):WaitForChild("face")

	cloneHum.DisplayDistanceType = "None"

	charClone.Parent = workspace
	charClone:PivotTo(CFrame.new(427.862, 8.75, -63.656))
	charClone.PrimaryPart.Rotation = Vector3.new(0, 90, 0)

	kid.Parent = workspace
	kid:PivotTo(CFrame.new(430.783, 8, -64.845))
	kid.PrimaryPart.Rotation = Vector3.new(0, 0, 0)

	charFace.Texture = dadFace.Texture

	local dadWalkTrack = cloneHum:LoadAnimation(walkAnim)

	local dadIdleTrack = cloneHum:LoadAnimation(idleAnim)

	local kidWalkTrack = kidHum:LoadAnimation(walkAnim)

	local kidIdleTrack = kidHum:LoadAnimation(idleAnim)

	local ikControl = Instance.new("IKControl")
	ikControl.Parent = cloneHum
	ikControl.Type = Enum.IKControlType.Position
	ikControl.EndEffector = charClone:WaitForChild("LeftHand", true)
	ikControl.ChainRoot = charClone:WaitForChild("LeftUpperArm", true)
	ikControl.Target = door:WaitForChild("Panel"):WaitForChild("IKatt")

	task.wait(0.5)

	for _, charPart in ipairs(charClone:GetChildren()) do
		if charPart:IsA("BasePart") then
			charPart.Anchored = false
			charPart.CanCollide = false
		elseif charPart.Name == "HumanoidRootPart" then
			charPart.CanCollide = true
			charPart.Anchored = true
		end
	end

	for _, charPart in ipairs(kid:GetChildren()) do
		if charPart:IsA("BasePart") then
			charPart.Anchored = false
			charPart.CanCollide = false
		elseif charPart.Name == "HumanoidRootPart" then
			charPart.CanCollide = true
			charPart.Anchored = true
		end
	end

	charClone.PrimaryPart.Anchored = true

	ts:Create(charClone.PrimaryPart, dad1ti, {CFrame = workspace:WaitForChild("dad1position").CFrame}):Play()
	dadWalkTrack:Play()
	dadWalkTrack:AdjustSpeed(0.4)

	task.wait(0.1)

	rs:WaitForChild("OpenDoor"):FireServer()

	task.wait(1.5)

	ikControl.Enabled = false

	dadWalkTrack:Stop()
	dadIdleTrack:Play()

	task.wait(1)

	kid.PrimaryPart.Anchored = true

	ts:Create(kid.PrimaryPart, kid1ti, {CFrame = workspace:WaitForChild("kid1position").CFrame}):Play()
	kidWalkTrack:Play()

	task.wait(1.6)

	ts:Create(kid.PrimaryPart, kid2ti, {CFrame = workspace:WaitForChild("kid2position").CFrame}):Play()

	task.wait(1.5)

	kidWalkTrack:Stop()
	kidIdleTrack:Play()

	task.wait(0.5)

	dadVoices:WaitForChild("voice1"):Play()
	dadFaceAnim(charFace)

	task.wait(2)

	endCS()
end

startRemote.OnClientEvent:Connect(startCS)
1 Like

Just wondering, have you checked that you have fired the start remote event and published new saved edits to Roblox?

ofc
image

you need to pass on a player variable inside the .OnServerEvent no?

this is a local script, it doesn’t make sense

then it should be .OnClientEvent, you can’t receive .OnServerEvent in local scripts

nvm, I’m very stupid, all I had to do was write: local char = plr.Character or plr.CharacterAdded:Wait()

1 Like

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