You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am trying to create a system that allows different dialogues to appear under certain conditions.
Completed is a bool I’ve made that represents when the player has completed the quest. CompletedSpoke stands for when the player has finished the final dialogue segment so it doesn’t reappear.
Value represents whether they’ve spoken with the NPC and got the quest already or not. -
What is the issue? Include screenshots/videos if possible!
Every time I test the script, it outputs nil even though in another script I previously set the variable to false. These are both server scripts. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried to look for similar posts with this problem and it was usually a local issue. But in this case, it has to do with two server scripts so it’s not very helpful.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you.
These are two scripts that are meant to piggyback off of one another.
Script #1
-- local cha = game:GetService("Chat")
game:GetService("Players").PlayerAdded:Connect(function(plr)
local value = game:GetService("ReplicatedStorage").Value
local value2 = game:GetService("ReplicatedStorage").complete
local value3 = game:GetService("ReplicatedStorage").completedspoke
value = false
value2 = false
value3 = false
script.Parent.Parent.ProximityPrompt.Triggered:Connect(function()
script.Parent.Parent.ProximityPrompt.Enabled = false
local player = plr.Character:WaitForChild("Humanoid")
if value == true then
print("value is true")
cha:Chat(game.Workspace.destiny.ChatBubble, "What are you doing back here? You still owe me my papers ~", Enum.ChatColor.Red)
task.wait(3)
cha:Chat(game.Workspace.destiny.ChatBubble, "Get back to work.", Enum.ChatColor.Red)
else if value == false then
print("recieved else, value is false")
player.WalkSpeed = 0
script.Parent.Parent.Sound:Play()
cha:Chat(script.Parent, "omg hey its you", Enum.ChatColor.Red)
task.wait(1) -- 5
cha:Chat(script.Parent, "heyy I know its pretty dark out here..", Enum.ChatColor.Red)
task.wait(1) -- 2
cha:Chat(script.Parent, "you and me.", Enum.ChatColor.Red)
task.wait(1) -- 5
cha:Chat(script.Parent, "perhaps we can make a deal", Enum.ChatColor.Red)
task.wait(1) -- 5
cha:Chat(script.Parent, "while that idiotic pitchfork is running around killing all your friends..", Enum.ChatColor.Red)
task.wait(1) -- 3
cha:Chat(script.Parent, "would you mind getting these papers for me?", Enum.ChatColor.Red)
task.wait(1) -- 5
plr.PlayerGui.choiceds.choice1.Text = "yeah sure.. but why do you want me to collect a bunch of papers? what are you gaining from this?>"
plr.PlayerGui.choiceds.choice2.Text = "no, go away destiny."
plr.PlayerGui.choiceds.choice1.Visible = true
plr.PlayerGui.choiceds.choice2.Visible = true
end
end
end)
end)
Script #2
local cha = game:GetService("Chat")
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.PlayerGui:WaitForChild("choiceds").choice1.MouseButton1Click:Connect(function()
plr.PlayerGui.choiceds.choice1.Visible = false
plr.PlayerGui.choiceds.choice2.Visible = false
local value = game:GetService("ReplicatedStorage").Value
local completed = game:GetService("ReplicatedStorage").complete
local completed2 = game:GetService("ReplicatedStorage").completedspoke
if value == false then
print("false")
else if value == true then
print("true")
else
print("nothing set :3")
end
end
if value == false and completed == false then
print("value was set to true")
value = true
cha:Chat(game.Workspace.destiny.ChatBubble, "No reason.", Enum.ChatColor.Red)
task.wait(5)
cha:Chat(game.Workspace.destiny.ChatBubble, "now, STOP ASKING DUMB QUESTIONS. get a move on, thanks ~ ^_^", Enum.ChatColor.Red)
plr.Character.Humanoid.WalkSpeed = 16
game.Workspace.destiny.ProximityPrompt.Enabled = true
game.Workspace.destiny.Sound:Stop()
else if value == true and completed == false then
print("value is true, completed is false")
cha:Chat(game.Workspace.destiny.ChatBubble, "What are you doing back here? You still owe me my papers ~", Enum.ChatColor.Red)
task.wait(3)
cha:Chat(game.Workspace.destiny.ChatBubble, "Get back to work.", Enum.ChatColor.Red)
game.Workspace.destiny.ProximityPrompt.Enabled = true
print("test")
else if completed == true and completed2 == false then
print("finsihed but special")
cha:Chat(game.Workspace.destiny.ChatBubble, "omg!! you actually got all my papers.. ^_^", Enum.ChatColor.Red)
task.wait(3)
cha:Chat(game.Workspace.destiny.ChatBubble, "THANKZIEEEESS! Looks like I won't be killing you today ~", Enum.ChatColor.Red)
task.wait(3)
cha:Chat(game.Workspace.destiny.ChatBubble, "Infact, because I'm so enthusiastic. I'll even give you a reward. Take 100 bless tokens ~", Enum.ChatColor.Red)
plr.leaderstats.BlessTokens.Value = plr.leaderstats.BlessTokens.Value + 100
game.Workspace.destiny.ProximityPrompt.Enabled = true
game.Workspace.destiny.Sound:Stop()
completed2 = true
else if completed == true and completed2 == true then
print("finished game")
cha:Chat(game.Workspace.destiny.ChatBubble, "oh hey there!", Enum.ChatColor.Red)
task.wait(3)
cha:Chat(game.Workspace.destiny.ChatBubble, "thx for the papers n stuff ~", Enum.ChatColor.Red)
task.wait(4)
cha:Chat(game.Workspace.destiny.ChatBubble, "if your planning to ask for a retry, you'll have to rejoin, ya sorry ~", Enum.ChatColor.Red)
task.wait(3)
else
print("nil")
end
end
end
end
end)
end)

If you need more information, please let me know! I have never used dev forum like this before. Any help is appreciated ^^
