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

LocalScript not working properly when true and false variables are changed?

I have a LocalScript for making a client sided BoolValue named "FFA" and it sets the BoolValue to true and false depending on what team you're on. Here is the code:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
 
local player = Players.LocalPlayer
local UpDatFFA = ReplicatedStorage:WaitForChild("UpdateFFA")
 
local ffa = Instance.new("BoolValue")
ffa.Name = 'FFA'
ffa.Parent = player.character
ffa.Value = true
 
local function FFAFired()
    if player.TeamColor == BrickColor.new("Black") then
        ffa.Value = false
    end
end
 
UpDatFFA.OnClientEvent:Connect(FFAFired)

This works perfectly fine, it creates the BoolValue named FFA with the value set to true in the Player's character. It even sets the BoolValue to false whenever the player is on the "Black" team.

However, here I have the same code with just the true and false variables swapped. It creates the BoolValue like it's supposed to, it's even set to false as it should be. Although, whenever the Player is swapped to the "Black" team, it doesn't set the BoolValue to true, even though I literally just swapped the true and false placements from the previous code. Here is the code:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
 
local player = Players.LocalPlayer
local UpDatFFA = ReplicatedStorage:WaitForChild("UpdateFFA")
 
local ffa = Instance.new("BoolValue")
ffa.Name = 'FFA'
ffa.Parent = player.character
ffa.Value = false
 
local function FFAFired()
    if player.TeamColor == BrickColor.new("Black") then
        ffa.Value = true
    end
end
 
UpDatFFA.OnClientEvent:Connect(FFAFired)

Can anyone tell me why this is happening or at least send me in the direction of fixing it? I would greatly appreciate the help.

1 answer

✓ Accepted answer

After reading the first part of your issue I understand it immediately. The issue is you can't send a object to the server with modified properties. So instead of sending the object you have to send the actual bool value instead.

1 comment

0

Thanks for the guidance! It helped me fix it.

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