BoolValue doesn't change

Hey! I’ve recently made a function for a RemoteEvent, that changes a player’s BoolValue. However, it doesn’t work at all (doesn’t change the value.)

The main issue though is that it doesn’t give me an error.

Fire event code:

game.Players.PlayerAdded:Connect(function()
	local player = game.Players.LocalPlayer
	local value = player.PlayerScripts:WaitForChild("IsPlayerAT")
	if player:GetRankInGroup(10928983) == 250 then
		ATEvents.ChangeATValue:FireServer(player)
	end
end)

OnEvent code:

local event = game.ReplicatedStorage.ATEvents.ChangeATValue

event.OnServerEvent:Connect(function(player)
	local value = player.PlayerGui:WaitForChild("IsPlayerAT")
	value.Value = true
end)

In the :FireSerer script, value is defined as so:

local value = player.PlayerScripts:WaitForChild("IsPlayerAT")

but in the .OnServerEvent script, value is defined differently:

local value = player.PlayerGui:WaitForChild("IsPlayerAT")

Change them to be the right one. Also, I recommend putting values not in the PlayerGui or somewhere else, but rather as a direct child to the Player object.

1 Like

Oh ye, I forgot to change the old variable and didn’t notice it :sweat_smile: Thank you!

Hmm actually… It still doesn’t change the value for some reason.

try print debugging. print when you fire the event and when it is recieved too, as well as the value itself before + after

It is not changing the value because remote event is not being fired.
remove game.Players.PlayerAdded event and try, it should work

Script
local player = game.Players.LocalPlayer
local value = player.PlayerScripts:WaitForChild("IsPlayerAT")
if player:GetRankInGroup(10928983) == 250 then
	ATEvents.ChangeATValue:FireServer()
end
1 Like

Thanks, the value now gets changed. However, I have come to another problem. Do you think you could help me with that aswell?

When the value is set to true, player should get a godmode (can’t be killed or damaged). However, it doesn’t work, and doesn’t give an error once again.

The code:

while wait() do
	if value.Value == true then
		player.Character.Humanoid.MaxHealth = math.huge
		player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
	end
end

use this instead

humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead,false)
1 Like

I still get killed when I’m on 0 HP.

if your weapons ignores forcefield try giving the player a forcefield

1 Like

That might fix it, but from visual side I don’t really wanna give a forceField to the player.

you could make the forcefield invisible
image

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