How to go about making an objective based story game

I have the build and modeling part done already. I have not script a game before and I want to make a story based horror game. Such as: “Go downstairs” , “Open the oven” “Take out the food in the oven” etc. I am questioning if I have to make these RemoteEvents and fire them in one big script. Also player and npc dialogue is confusing… do I make this in a set script and after each click the text changes. I have an idea for the games framework and I’ve seen videos on how to make story games. However, the dialogue is all in one big script filled with remote events. This is impractical since the game will be 15 min long filled with lots of dialogue.

2 Likes

Yes, using remote events is better so every player in the game can see them. Also, make it one script; it’s better than a lot of scripts.

An example in the local script add an invisible big wall that covers the way to the cave, and when the player enters the cave, he will touch the part. When the player touches the part, he will fire a remote to the server, and the dialogue will say, “You Entered The Cave.”

Feel free to ask any other questions

I see… if it helps the game is single player.

Also, this can work after so much dialogue and there will be a lot of dialogue. I feel like one script will be super long and not practical. If I have to go back to add something, I’d have to surf through many lines of code. Additionally, if I had easter eggs that ran code when triggered, wouldn’t I have to add that to the huge script?

This is how I would set something like this up:

For this example, I will Use 1 Remote Event, and 1 Binable event (If you don’t know the difference, A basic rundown: Remote allows Server to Client or Client to server communication. Binable allows Server to Server or Client to Client communication )

I would have A Screen Gui with a textlabel to display the text ofc. Assuming you have everything set up, lets get to scripting!

Basicially an Idea is Ima have One local script, One server script. The local script will run all the text, while the server script will do most of the detection and tell the client the dialog. So here is an example On what a possible client script would like w/ an explaing guide:

This is An example of what A local script could look like:

-- These would be the pathways to the different events. Change them to the pathway of the object. In my example these objects are in ReplicatedStorage with their names
local RemoteEvent = game.ReplicatedStorage.DisplayTextServer
local BinableEvent =  game.ReplicatedStorage.DisplayTextClient

local TextLabelToDisplayText = script.Parent -- change this to the pathways of the textlabel your wanting to Display. I though recommend if you use this, to put this local script inside the textlabel so you don't have to change this


local function DisplayText(AllText) -- I'm setting a function, with one variable which will host the all text in a table 
TextLabelToDisplayText.Visible = true -- Makes the TextLabel visible 
for i, EachText in AllText do -- EachText is One Text out of the table. If we wanted multiple different texts displayed
    TextLabelToDisplayText.Text = EachText --Changes it so it is displayed
     task.wait(5) --Time for player to read the current text, if you have more then one. Feel free to change if you want more/less time
   end 
TextLabelToDisplayText.Visible = false -- Makes the TextLabel invisible 
end

RemoteEvent.OnClientEvent:Connect(function(AllText)
DisplayText(AllText)
end)

BinableEvent.Event:Connect(function(AllText)
DisplayText(AllText)
end)

Boom! There you have it. This is the ‘big script’ but we can make it not big by using methods and shortcuts so you don’t have to use many different events. Now this is an example and explaining of my thinking proccess. You do not have to use this at all, but hopefully just seeing it and having me explain it atleast helps?

Also you will notice… Theres no text with my method… Thats because I made it nice and easy to display the text in other scripts! It takes one line! You hear me! One line! You can do this by

This is for using a Server Script and wanting to display text:

--The first bit is the the pathway to the Remote Event. For me its in Rep. storage
game.ReplicatedStorage.DisplayTextServer:FireAllClients({"Hello. This is text I want to be displayed", "Oh wow... This is the second message for the text to be displayed",})
--The last bit is the Text that you would want! You can add as Many messages as you want, As lone as you follow the format rules, with the " " quote marks and a comma, with {} wrapping it  Ex: {"First Message", "Second Message",}

This is for using a Local Script and wanting to display text:

--The first bit is the the pathway to the Binable Event. For me its in Rep. storage
game.ReplicatedStorage.DisplayTextClient:Fire({"Hello. This is text I want to be displayed", "Oh wow... This is the second message for the text to be displayed",})
--The last bit is the Text that you would want! You can add as Many messages as you want, As lone as you follow the format rules, with the " " quote marks and a comma, with {} wrapping it  Ex: {"First Message", "Second Message",}

Again this is an example on doing something like this! Its only a couple of lines, and only takes 1 of each type of Event to display text, with the added feature of being able to display many messages (Good for dialog). Again, My point wasn’t saying ‘use this script’ but atleast to explain to you how doing something like this, can be simplified. We always want to display text → Just the messages/Text is different each time.

Hope this helps! And/or allows you to walk away with something intresting or something new you learned!

2 Likes

Thank you! I didn’t see this at this approach. I appreciate the explanations and examples to help me learn. I’ll definitely try this layout for npc dialogue :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.