I’m trying to activate a cutscene after you have collected enough items in my game but i don’t know how to do that.
The leaderboard and Cutscene both work well by themselves so I’m sure its not that.
I would appreciate if someone could help.
Thank you very much
You can essentially fire a specific client after a condition is met.
The logic:
Upon the collection of said item (I presume your keeping count already) you keep an active tally of how many they’ve collected. Chances are this is likely some touch event, or an event which is exclusive to the client being asked upon the server. Just check if the condition is met every time you add to your tally - if it is then fire the client.
So what we can do is:
- We can use the :FireClient() argument on a remote event in order to trigger specifically that client. Then we have a specifically pre-determined routine on the client binded to that specific event which displays the cutscene or whatever.
- The server transfers a UI to the client and then if its a local script, if placed in PlayerGui it will automatically play.
Documentation for this:
Thanks man. It works!!! I had to learn how to use Remote events for this haha, but I still have a question.
I know its really dumb and it should (probably) be like common knowledge… but how do i know who to play it for? I had to write my name for it to play for me
local RepSto = game:GetService("ReplicatedStorage")
local PlayCin = RepSto:WaitForChild("PlayCinematic")
if playerTotal.Value == 1 then
print("Works")
PlayCin:FireClient(game.Players:WaitForChild("Player1"))
--I wrote my name instead of Player1 but i don't know how to detect who did it to write it here
end
I know its really dumb but im stuck there.
Thanks for the trouble
Well, if there’s a place in your script that changes the playerTotal value, you could always check if its value meets a certain criteria.
Tell me, is there a part in this script that changes the playerTotal value? And if so, copy down that part and send it here.
Yep. All of this is in the tool that collects the items that is in StarterPack.
local backpack = tool.Parent
local player = backpack.Parent
local playerStats = player:FindFirstChild("leaderstats")
--playerTotal checks how many items i have
--playerSpaces is how many items i can hold.
local playerSpaces = playerStats:FindFirstChild("Bag")
local playerTotal = playerStats:FindFirstChild("Total Ores")
if playerTotal.Value < playerSpaces.Value then
playerTotal.Value = playerTotal.Value + 1
end
alright, so after you add 1 point to the playerTotal value, you can do another if
statement to check if it is over a certain value
if playerTotal.Value >= 1 then
print("works")
PlayCin:FireClient(player)
end
I am embarassed of how easy it was. Thank you.
Thought I’d add that you may just wanna keep it at ==
and not >=
, because every time a point is added, it would fire the cutscene.