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.
--name of cutscene
cutscene_id = "Cutscene1"
--"infinite" = show whenever button is pressed
--"spawn" = show once per spawn
--"enter" = show once per gameplay
show_rule = "infinite"
--if show_rule is "infinite", how long after the end of showing the cutscene can they see it again?
debounce_time = 1
----------------------------------------
button = script.Parent
ls = button.CutsceneLocalScript
d = false
function showCutscene(player, sync)
local n = ls:clone()
n.Parent = player.Backpack
if not sync then while n.Parent do wait() end end
end
function getTags(p)
local cs = p:FindFirstChild("Cutscenes")
if not cs then
cs = Instance.new("IntValue", p)
cs.Name = "Cutscenes"
end
return cs
end
function checkTag(p)
return getTags(p):FindFirstChild(cutscene_id)
end
function setTag(p)
local t = Instance.new("IntValue", getTags(p))
t.Name = cutscene_id
end
function hasSeenCutsceneEnter(player) return checkTag(player) end
function hasSeenCutsceneSpawn(player) return checkTag(player.Character) end
function recSeenCutsceneEnter(player) setTag(player) end
function recSeenCutsceneSpawn(player) setTag(player.Character) end
function onTouch(part)
--get player
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if not player then return end
--check already watching
if player.Backpack:FindFirstChild(ls.Name) then return end
--check debounce
if d then return end d = true
if show_rule == "enter" then
if not hasSeenCutsceneEnter(player) then
showCutscene(player)
recSeenCutsceneEnter(player)
end
elseif show_rule == "spawn" then
if not hasSeenCutsceneSpawn(player) then
showCutscene(player)
recSeenCutsceneSpawn(player)
end
else
showCutscene(player)
wait(debounce_time)
end
d = false
end
button.Touched:connect(onTouch)
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.

1 comment
100% true. You can't code if you don't know how.