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?
Upon breaking the door, you can fire an Event to tell that the player has unlocked the door.
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
endtypewrite(script.Parent, “Where should i go now?”, 0.05)
but i cant get it so when the event is fired it begins typewriting
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
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
endtypewrite(script.Parent, “Huh? A yellow door! Wonder how I could unlock it.”, 0.05)
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
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
yep!
you should fire the event in the same script as the script where it destroys the door, if it is a server script
Uhh it doesnt work now
local SoftBlock = script.Parent
local Frame = game.StarterGui.HeatReaction.ImageLabel
local Player = game.Players.LocalPlayerSoftBlock.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
did you try checking the output?
yeah it says FireClient: player argument must be a Player object
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.
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.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.