Boolvalue won't change in other scripts

You can write your topic however you want, but you need to answer these questions:

  1. 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.

  2. 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.

  3. 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)

Screenshot_6

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

  1. Can you send a screenshot of Output?

  2. Can you send the script that changes the boolean values?

  3. I have noticed a problem in the first script:

local value = game:GetService("ReplicatedStorage").Value
	local value2 = game:GetService("ReplicatedStorage").complete
	local value3 = game:GetService("ReplicatedStorage").completedspoke
	value = false
	value2 = false
	value3 = false 

You get the values but then you set them all to false…? Is this intentional?

Here you go!

1 Like

Hello, just letting you know I made edits to my first post. ^^

I would try adding the values in the player instead and not keep them in rep storage

The Boolean values change in that part of the script.
It is intentional, I have it where if the values were false (which I assume is done by default when there is no assigned value, but I could be wrong) it would execute the first dialogue segment and set the value to true in the second script.
But I noticed that it wouldn’t execute at all and acted almost as if the values weren’t set to anything. So, I assumed they had no assigned value thus which is why I added the first part.

I did this previously and still got the same results. However, it was inside of the PlayerGui so I’m not sure if that counts or not.

PlayerGUI is client-side, prone to exploits.

Oh I see the changes now, sorry for the oversight.

I noticed you are changing the variables, which wouldn’t work in this case. You would need to do value.Value = true for example, where the variable value is referencing the path of the value object and then .Value would get you the value of that Value instance.

Also another question: are complete and completedspoke and Value all BoolValues? if they are, you are only referencing the instance itself and not the actual property called “Value” contained within the BoolValue instance, which may be why there is no response.

I was not aware of that, thank you for letting me know! ^^

1 Like

Yes, they are all BoolValues! By instance what are you referring to exactly, the bool itself? If so, how should I be writing these variables instead?

By instance, i mean the item in the Explorer / the thing you add when you add a BoolValue. When you click on the BoolValue instance, you can see in the Properties window ( i think thats what its called) that there is a property called Value.

I would do this:

local value = game:GetService("ReplicatedStorage").Value
	local value2 = game:GetService("ReplicatedStorage").complete
	local value3 = game:GetService("ReplicatedStorage").completedspoke
--when i reference/change it later:
value.Value = true
value2.Value = false
value3.Value = true --etc

Ah, I understand now! Thank you so much for your help ^^ :heartpulse:

1 Like

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