Why is this script not working?

Hi,

I used the plugin from CloneTrooper to make cutscenes. The cutscenes are fine but the scripts dont work. I used a playertouch script (script is from clonetrooper) but its not working!


(picture from the error)
tested in studio

CutsceneSender:

cscript = script.Parent:WaitForChild("CutsceneScript")

if script.Parent:findFirstChild("SkipCutsceneGuiValue") then
	script.Parent.SkipCutsceneGuiValue.Parent = cscript
	script.Parent.SkipCutsceneGui.Parent = cscript
end

debounce = false

function onTouched(hit)
	if debounce == true then return end
	if hit.Parent:findFirstChild("CutsceneScript") then return end -- If theres already a cutscene running, then don't do anything.
	if not hit.Parent:findFirstChild("Humanoid") then return end -- If theres no humanoid,  then don't do anything
	if not game.Players:GetPlayerFromCharacter(hit.Parent) then return end -- If its not a player, then don't do anything.
	debounce = true
	script.Parent.BrickColor = BrickColor.new("Black")
	local cutsceneScript = cscript:clone()
	cutsceneScript.Parent = hit.Parent
	cutsceneScript.Disabled = false
	repeat wait () until cutsceneScript.Parent == nil
	wait(3)
	script.Parent.BrickColor = BrickColor.new("Dark stone grey")
	debounce = false
end

script.Parent.Touched:connect(onTouched)

CutsceneScript: (localscript and its grey but idk why

local HttpService = game:GetService("HttpService")
local data = HttpService:JSONDecode(script.CutsceneData.Value)

local c = game.Workspace.CurrentCamera
local rs = game:GetService("RunService").RenderStepped

function tweenCam(c1, f1, time, fov, roll)
	local c0,f0,fv0,r0,frames = c.CoordinateFrame,c.Focus,c.FieldOfView,c:GetRoll(),time/0.015
	for i = 1,frames do
		c.CameraType = "Scriptable"
		c.CoordinateFrame = CFrame.new(c0.p:lerp(c1.p,i/frames),f0.p:lerp(f1.p,i/frames))
		c.FieldOfView = (fv0+(fov-fv0)*(i*(1/frames)))
		c:SetRoll(r0+(roll-r0)*(i*(1/frames)))
		rs:wait()
	end
end

print("Running")

c.CameraSubject = nil	
c.CameraType = "Scriptable"
c.CoordinateFrame = CFrame.new(unpack(data[1].c1))
c.Focus = CFrame.new(unpack(data[1].f1))
c.FieldOfView = data[1].FOV
c:SetRoll(data[1].Roll)

if script:findFirstChild("SkipCutsceneGuiValue") then
	local gui = script.SkipCutsceneGui:clone()
	gui.Parent = game.Players.LocalPlayer.PlayerGui
	gui.Cutscene.Value = script
	gui.Main.Debug.Disabled = false
	script.SkipCutsceneGuiValue.Value = gui
end

for i = 2,#data do
	tweenCam(CFrame.new(unpack(data[i].c1)),CFrame.new(unpack(data[i].f1)), data[i].step, data[i].FOV, data[i].Roll)
end

c.CameraSubject = game.Players.LocalPlayer.Character.Humanoid	
c.CameraType = "Custom"
c.FieldOfView = 70

if script:findFirstChild("SkipCutsceneGuiValue") then
	if script.SkipCutsceneGuiValue.Value ~= nil then
		script.SkipCutsceneGuiValue.Value:Destroy()
	end
end

script:Destroy()local HttpService = game:GetService("HttpService")
local data = HttpService:JSONDecode(script.CutsceneData.Value)

local c = game.Workspace.CurrentCamera
local rs = game:GetService("RunService").RenderStepped

function tweenCam(c1, f1, time, fov, roll)
	local c0,f0,fv0,r0,frames = c.CoordinateFrame,c.Focus,c.FieldOfView,c:GetRoll(),time/0.015
	for i = 1,frames do
		c.CameraType = "Scriptable"
		c.CoordinateFrame = CFrame.new(c0.p:lerp(c1.p,i/frames),f0.p:lerp(f1.p,i/frames))
		c.FieldOfView = (fv0+(fov-fv0)*(i*(1/frames)))
		c:SetRoll(r0+(roll-r0)*(i*(1/frames)))
		rs:wait()
	end
end

print("Running")

c.CameraSubject = nil	
c.CameraType = "Scriptable"
c.CoordinateFrame = CFrame.new(unpack(data[1].c1))
c.Focus = CFrame.new(unpack(data[1].f1))
c.FieldOfView = data[1].FOV
c:SetRoll(data[1].Roll)

if script:findFirstChild("SkipCutsceneGuiValue") then
	local gui = script.SkipCutsceneGui:clone()
	gui.Parent = game.Players.LocalPlayer.PlayerGui
	gui.Cutscene.Value = script
	gui.Main.Debug.Disabled = false
	script.SkipCutsceneGuiValue.Value = gui
end

for i = 2,#data do
	tweenCam(CFrame.new(unpack(data[i].c1)),CFrame.new(unpack(data[i].f1)), data[i].step, data[i].FOV, data[i].Roll)
end

c.CameraSubject = game.Players.LocalPlayer.Character.Humanoid	
c.CameraType = "Custom"
c.FieldOfView = 70

if script:findFirstChild("SkipCutsceneGuiValue") then
	if script.SkipCutsceneGuiValue.Value ~= nil then
		script.SkipCutsceneGuiValue.Value:Destroy()
	end
end

script:Destroy()

Thanks!

1 Like

the script is grey because… it’s disabled

k but its no solution. I didnt disabled it :slight_smile:

I mean you need to enable it to make it work

1 Like

i dont think so because on all videos i saw from the plugin, the script was disabled and why should the creator from the plugin disable it if it dont work so?

i tested it with enabled script but it didnt work

Where’s CutsceneData located at?

Where is the local script located at? Also, if it’s in the workspace, the local script won’t run.

You can find more info about Local Scripts here.

It looks like your trying to find a child of a local script, which local scripts are the first things that loads meaning it will error. Add WaitForChilds to prevent it

wdym with cutscene data? CutscenePlayer and CutsceneScript are in the part.

where i need to add it? can you send the full script?

This is why it isn’t running, you can’t put local scripts in workspace.

the localscript is in the part and the part is in the workspace. What should i change?

where i need to put it in? but the localscript is disabled

When defining an object, you would put :WaitForChild(“name”)

okay i will try it. :smiley: sdsdsds

I would move it to StarterPack and edit it accordingly, also, his plugin is deprecated.

If you could send us a picture of the workspace that would help us a lot. We don’t have a clear picture in our mind.

Hi here is the workspace screen:

image

Should i move all to StarterPack or only the localscript because the localscript has some lines in: like script.example.example and when i only move the localscript the system would break.

Like I said up above, you might need to edit it a little. But I assume you should only move the local script.

should i enable it? because its basically disabled