Firstly, Sorry for the length of this. Secondly here is the info:
I am making a cutscene that happens when activated by walking through a block and as soon as the cutscene starts the player will not be able to move until the cutscene has finished. As the player will pass through the activator block later on in the game, I only want the cutscene to happen the very first time the player touches the brick; however, I want it so that if they leave and re-join they will be able to activate the cutscene again when they pass through the brick the first time.
I have the cutscene itself scripted, however I haven't got the 'one-time use' and the 'player movement paused' codes scripted to work
The code is in a LocalScript placed inside the StarterGui folder as it didn't work when put in workspace
Here is the code I have got stuck on: (Sorry It's Long)
-------------------I'm Fine From This Part Down To Line 66-------------------
wait(3)
local tweenservice = game:GetService("TweenService")
local camera = game.Workspace.CurrentCamera
local l10 = game.Workspace.ObbyStructure.L10
local function Movecamera(Startpos, Endpos, Duration, EasingStyle, EasingDirection)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = Startpos.CFrame
local Cutscene = tweenservice:Create(camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = Endpos.CFrame})
Cutscene:Play()
wait(Duration)
end
local function cutscene10(player)
local OGp = camera.CFrame
local starterpart = Instance.new("Part", l10)
starterpart.Name = "starterpart"..player.Name
starterpart.Anchored = true
starterpart.CanCollide = false
starterpart.Size = Vector3.new(1, 1, 1)
starterpart.Transparency = 1
starterpart.CFrame = OGp
starterpart.CastShadow = false
wait (0.1)
Movecamera(camera, starterpart, 0.5, Enum.EasingStyle.Circular, Enum.EasingDirection.Out)
Movecamera(starterpart, l10.Pos1, 1, Enum.EasingStyle.Circular, Enum.EasingDirection.Out)
wait(1.5)
Movecamera(l10.Pos1, l10.Pos2, 2.5, Enum.EasingStyle.Circular, Enum.EasingDirection.Out)
wait(2.5)
Movecamera(l10.Pos2, l10.Pos3, 2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
Movecamera(l10.Pos3, l10.Pos4, 2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
wait(2.5)
Movecamera(l10.Pos4, l10.Pos3, 2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
Movecamera(l10.Pos3, l10.Pos5, 2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
wait(0.5)
l10.door.platform.Material = Enum.Material.Neon--first loop
l10.door.platform.Color = Color3.new(0, 255, 0)
wait(0.2)
l10.door.platform.Material = Enum.Material.Metal
l10.door.platform.Color = Color3.new(163, 162, 165)
wait(0.1)
l10.door.platform.Material = Enum.Material.Neon--second loop
l10.door.platform.Color = Color3.new(0, 255, 0)
wait(0.2)
l10.door.platform.Material = Enum.Material.Metal
l10.door.platform.Color = Color3.new(163, 162, 165)
wait(0.1)
l10.door.platform.Material = Enum.Material.Neon--third loop
l10.door.platform.Color = Color3.new(0, 255, 0)
wait(0.2)
l10.door.platform.Material = Enum.Material.Metal
l10.door.platform.Color = Color3.new(163, 162, 165)
wait(0.7)
Movecamera(l10.Pos5, l10.Pos1, 2.5, Enum.EasingStyle.Circular, Enum.EasingDirection.Out)
wait(2)
Movecamera(l10.Pos1, starterpart, 2.5, Enum.EasingStyle.Circular, Enum.EasingDirection.Out)
wait(2)
l10:WaitForChild("starterpart"..player.Name):Destroy()
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
end
-------------------FROM HERE IS WHERE I START GETTING ISSUES-------------------
local db = false
cutsceneplayed = {} --the table didn't work as it was a local script
local function Hit(hit)
local player = hit.Parent
if not cutsceneplayed[player.Name]then
if db == false then
db = true
local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Disable() -- BIG ISSUE USING THIS (see notes below)
cutscene10(player)
controls:Enable() -- This Works but Not properly (see Error Notes below)
cutsceneplayed[player.Name] = true
for winnerId,_ in pairs(cutsceneplayed) do
print(winnerId)
end
db = false
end
end
end
l10.CutsceneActivator.Touched:Connect(Hit)
Error Notes:
Obviously the table didn't work as it was in a local script
The controls:Disable() function works fine until the character dies, as for some reason when the player respawns, they can't move at all - plus the controls:Enable() won't fix it!
Any help would be much appreciated, especially as it took me so long to get this far.
Thanks in Advance, IncredibleTeamAidan

3 comments
try moving the
local controls = ...line outside of the function. That alone should solve your problem as when it is in the function, every time you run the function, it creates an entirely new variable that can't be accessed when you run it again.And you can have any type of variable in a local script. Your table didn't work not because it was a table, but because of what you did with the table.
@SteamG0D moving the
local controls = ...didn't make a difference