Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make this code activate a cutscene by clicking on a part?

Asked by 4 years ago

So I have made a button that has a ClickDetector and the script, but the problem is that it doesn't work from me simply clicking on the button.

Many tutorials on YouTube cover how to do activate cutscenes by touching the part but I don't want that, when I look at this code, I don't know what a single strip of code does because I have very basic coding skills and this is from a cutscene plugin from Ozzypig, once again no tutorials on YouTube on how to do this.

01--name of cutscene
02cutscene_id = "Cutscene1"
03 
04--"infinite"    = show whenever button is pressed
05--"spawn"       = show once per spawn
06--"enter"       = show once per gameplay
07show_rule = "infinite"
08 
09--if show_rule is "infinite", how long after the end of showing the cutscene can they see it again?
10debounce_time = 1
11 
12----------------------------------------
13 
14button = script.Parent
15ls = button.CutsceneLocalScript
View all 76 lines...

The context is that a player clicks on the button to solve a puzzle, therefore triggering this cutscene where the camera goes from Point A to Point B, I also added a sound id in the model but I don't where to put the code in to set it off.

2 answers

Log in to vote
1
Answered by
esepek 103
4 years ago

Hey there, first of all my suggestion for you is to get better at scripting instead of using premade stuff like plugins, models or scripts from the internet. Because if you dont understand the code and you want to change something you will have to ask people again. I would buy some books about coding and read them. For example the advanced coding book made by Heath Haskins. Also once you are able to script a little go to discord servers and go into a voice chat. Then talk to people ask questions and show people your code and get some feedback.

Now to your question.

  1. put a folder in workspace wich is called CutsceneParts

  2. put your part a and part b into that folder. IMPORTANT: call the first part a and the second one b | excactly how I wrote the names here | and make sure to Anchor them and set Transparency to 1

  3. Put a part in workspace and name it StartCutcenePart

  4. Add a ClickDetector to StartCutcenePart

  5. put a local script into StarterPlayer>StarterPlayerScripts

then paste the following code:

01--Variables--
02 
03local CP = workspace.StartCutcenePart --workspace.StartCutcenePart is a reference to the part activating the cutscene. put your Parts name instead of StartCutcenePart--
04local CD = CP.ClickDetector --The ClickDetector
05local Cam = workspace.CurrentCamera --Camera
06local CutsceneFolder = workspace.CutsceneParts -- The CutsceneFolder
07local TimeBetweenEachCutscenePart = 4 -- The time the Tween("Animation") between point a and b takes
08local playing = false --A variable to debounce
09local TS = game:GetService("TweenService") -- Tweenservice
10local TI = TweenInfo.new(TimeBetweenEachCutscenePart,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut) --Creating the Tweeninfo
11 
12--functions--
13local function StartCutscene(start,destination) -- a function called StartCutscene
14    Cam.CameraType = "Scriptable" --setting the cameramode to "Scriptable"
15    if CutsceneFolder:FindFirstChild(destination) and CutsceneFolder:FindFirstChild(start) then --check if the block the animation should tween to and from is found
View all 32 lines...
0
100% true. You can't code if you don't know how. cancle5 120 — 4y
Ad
Log in to vote
0
Answered by
cancle5 120
4 years ago
Edited 4 years ago

Basically, first add a click detecter too the part.

If you want to start to make advanced stuff like this first you needa learn scripting and get the basics.

Also the folowing code you used wont work as needed and i suggust using something else You can use this

1local part = -- the part
2local detecter = part.ClickDetecter
3 
4detecter.MouseButton1Click:Connect(function()
5    -- the script
6end)

or you can just easily change the function of your script I don't think this script would work and i would make it differently.

If ya need some help you can dm me discord cancle5#0035

01--name of cutscene
02cutscene_id = "Cutscene1"
03 
04--"infinite"    = show whenever button is pressed
05--"spawn"       = show once per spawn
06--"enter"       = show once per gameplay
07show_rule = "infinite"
08 
09--if show_rule is "infinite", how long after the end of showing the cutscene can they see it again?
10debounce_time = 1
11 
12----------------------------------------
13part = script.Parent
14detecter = part.ClickDetecter
15ls = button.CutsceneLocalScript
View all 76 lines...

Answer this question