Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to fix boolean being false?

I'm trying to make a scoreboard, and even though I tried to tell the server that a specific boolean value was true, I printed to check the value and it returned as false. When I tried printing the DetermineValue, it printed my ROBLOX name, (FriendBandsX) instead of showing true or false.. maybe I used the wrong thing. I just don't know how to utilize the data that I'm sending to the server and I'm confused.

Server-side on top, client on bottom

-- GUI Variables
local GroupID = 3625788
local MinimumRankRequired = 1
local DeleteGUI = game.ReplicatedStorage.DeleteGUI
-- Remotes
local DataHold = game.ReplicatedStorage.DataHolder
local F = game.ReplicatedStorage.F
-- Away Variables
local AwayScore = game.Workspace.Scoreboard.MainGUI.MainFrame.Scores.AwayScore.Runs
local HomeScore = game.Workspace.Scoreboard.MainGUI.MainFrame.Scores.HomeScore.Runs
local descendants = game.ReplicatedStorage.F:GetDescendants()
-- Functions
local function HandleRemotes(DetermineValue)
	for i, descendant in pairs(descendants) do
		if descendant:IsA("BoolValue") then
			print(descendant.Value)
			if descendant.Name == "AddingAwayRuns" and descendant.Value == true then
				AwayScore.Value = AwayScore.Value + 1
				AwayScore.Parent.Text = AwayScore.Value
			elseif descendant.Name == "AddingHomeRuns" and descendant.Value == true then
				HomeScore.Value = HomeScore.Value + 1
				HomeScore.Parent.Text = HomeScore.Value
			end
		end
	end
end

DataHold.OnServerEvent:Connect(HandleRemotes)

Client-side:

-- Remotes
local DataHold = game.ReplicatedStorage.DataHolder
local F = game.ReplicatedStorage.F

script.Parent.MouseButton1Click:Connect(function()
	DataHold:FireServer(F.AddingAwayRuns.Value == true)
end)

1 answer

✓ Accepted answer

Alright so first, when you use RemoteEvents to communicate between Server and Client, a Player must be the first argument for the Server, then follow by additional value. So in your case, you tried to put "DetermineValue" which is the Player as the first argument, that is why when you try to print(DetermineValue), it printed the player's name.

To fix this:

local function HandleRemotes(Player, DetermineValue)
	-- Your codes here
end

For the other boolean value, since you are trying to pass a value from the Client, the Server won't recognise it because there's 2 worlds in roblox. 1 is the Client's world and the other is the Server's world. In order for both worlds to know that something is changed, you must do it on the Server-side. Therefore, delete the argument in your LocalScript and write it in your ServerScript instead.

This discussion is preserved as it was. New answers, comments, and votes are closed.