I have a script in workspace that is meant to check if a player has a value set to true, but even if the player has the value set to true, the script still does not run for the player.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Wait()
if Player.Folder.BoolValue.Value == true then
print("Success")
-- Run Script
end
end)
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
LocalPlayer.Folder.BoolValue.Changed:Connect(function()
if LocalPlayer.Folder.BoolValue.Value == true then
print("Success")
end
end)
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
if LocalPlayer.Folder.BoolValue.Value == true then
print("Success")
end
game.Players.PlayerAdded:Connect(function(Player)
local Folder = Player:WaitForChild("Folder")
local Bool = Folder:WaitForChild("BoolValue")
Bool.Changed:Connect(function(NewBool)
if NewBool then
--Run code.
end
end)
end)
Your if conditional statement would only ever be checked once (for each player when they first join), you need to listen to the BoolValue’s “.Changed” event to detect when the value of its “Value” property changes.
This works, but is there a way to run this same solution when the player dies?
This Code:
Player.Character:WaitForChild("Humanoid").Died:Connect(function()
wait(3.8)
local Folder = Player:WaitForChild("Folder")
local Bool = Folder:WaitForChild("BoolValue")
Bool.Changed:Connect(function(NewBool)
if NewBool then
-- Code