Story Game Dialogue System go further

so as of recently i was trying to make a kind of story game and at the first task you go through the door. But how do i make it so it detects if the player did it and a dialogue system goes further?

4 Likes

Upon breaking the door, you can fire an Event to tell that the player has unlocked the door.

2 Likes

ive already tried that but i cant seem to get it that it writes a new dialogue
this is the dialogue script i use

local function typewrite(object,text,length)
for i = 1,#text,1 do
local sound = Instance.new(“Sound”)
sound.Parent = game.Workspace
sound.SoundId = “rbxassetid://552900451”
sound.Name = “DialogueSound”
sound:Play()
object.Text = string.sub(text,1,i)
wait(length)
end
for i,v in pairs(game.Workspace:GetChildren()) do
if v.Name == “DialogueSound” then
v:Destroy()
end
end
end

typewrite(script.Parent, “Where should i go now?”, 0.05)

but i cant get it so when the event is fired it begins typewriting

1 Like

What do you mean you can’t get it to write a new dialogue?
I’m assuming you’re doing the typewriting dialogue from the client, so upon breaking the door fire the event from the server to the client and do the typewriting

1 Like

where do i put the line of code of the event?

game.ReplicatedStorage.Task1Completed.OnClientEvent:Connect(function()

local function typewrite(object,text,length)
for i = 1,#text,1 do
local sound = Instance.new(“Sound”)
sound.Parent = game.Workspace
sound.SoundId = “rbxassetid://552900451”
sound.Name = “DialogueSound”
sound:Play()
object.Text = string.sub(text,1,i)
wait(length)
end
for i,v in pairs(game.Workspace:GetChildren()) do
if v.Name == “DialogueSound” then
v:Destroy()
end
end
end

typewrite(script.Parent, “Huh? A yellow door! Wonder how I could unlock it.”, 0.05)

1 Like

sigh

you’re going to have a variable around function(), like this:

game.ReplicatedStorage.Task1Completed.OnClientEvent:Connect(function(Text)

don’t forget to change the “Huh? A yellow door! Wonder how I could unlock it.” to the “Text” variable
then on the server, for each action (let’s say a yellow door broken down) you will fire the event on a server script exactly like this:

game.ReplicatedStorage.Task1Completed:FireClient(Player, "I somehow broke down the yellow door.")

my apologies for the vague explanation. if you have anything unclear please do tell

2 Likes

so like this?

game.ReplicatedStorage.Task1Completed.OnClientEvent:Connect(function(Text)

local function typewrite(object,text,length)
for i = 1,#text,1 do
local sound = Instance.new(“Sound”)
sound.Parent = game.Workspace
sound.SoundId = “rbxassetid://552900451”
sound.Name = “DialogueSound”
sound:Play()
object.Text = string.sub(text,1,i)
wait(length)
end
for i,v in pairs(game.Workspace:GetChildren()) do
if v.Name == “DialogueSound” then
v:Destroy()
end
end
end
typewrite(script.Parent, Text, 0.05)
end)

and where do i put the server script in?

sorry for the hard time i really cant code

1 Like

yep!

you should fire the event in the same script as the script where it destroys the door, if it is a server script

2 Likes

Uhh it doesnt work now

local SoftBlock = script.Parent
local Frame = game.StarterGui.HeatReaction.ImageLabel
local Player = game.Players.LocalPlayer

SoftBlock.Touched:Connect (function (hit) – When the part is touched by something
if hit.Name == “NOTHING” then – If the other part is named Explosion1
game.Workspace.ExplosionEffect.Position = SoftBlock.Position
local Sound = Instance.new(“Sound”)
Sound.Parent = game.Workspace
Sound.SoundId = “rbxassetid://2674547670”
Sound:Play()
wait(1)
SoftBlock:Destroy()
wait(1)
game.ReplicatedStorage.Task1Completed:FireClient(Player, “I somehow broke down the yellow door.”)
game.Workspace.ExplosionEffect.MIDDLE.EXPLOSION01.Rate = 0
game.Workspace.ExplosionEffect.MIDDLE.EXPLOSION02.Rate = 0
game.Workspace.ExplosionEffect.MIDDLE.EXPLOSION03.Rate = 0
game.Workspace.ExplosionEffect.MIDDLE.EXPLOSION04.Rate = 0
wait(2)
game.Workspace.ExplosionEffect.Position = game.Workspace.ExplosePos.Position
game.Workspace.ExplosionEffect.MIDDLE.EXPLOSION01.Rate = 5
game.Workspace.ExplosionEffect.MIDDLE.EXPLOSION02.Rate = 100
game.Workspace.ExplosionEffect.MIDDLE.EXPLOSION03.Rate = 100
game.Workspace.ExplosionEffect.MIDDLE.EXPLOSION04.Rate = 100
end
end)

'the first part works but the explosion doesnt go away anymore

1 Like

did you try checking the output?

1 Like

yeah it says FireClient: player argument must be a Player object

1 Like

Is your game singleplayer?
If not you can just use :FireAllClients() so you don’t need to include the “Player” variable and let the dialogue typewrite to every player in the game.

1 Like

Judging on how you’ve set up Player this is probably in a localscript. Just move your typewrite script there and play it, or just use a ModuleScript to ease things up.

2 Likes

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