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