FireClient detect check only one people, problem

Hi, i create a Story mode to improve some part of my skill and i have found a problem.
All story is based on Server Script in ServerScriptService (Text edit & wait)

I try to make a point system when player win or no, if the player dead i don’t want he get point.
I have make this code :

				for i, plr in pairs(game.Players:GetPlayers()) do
					game.ReplicatedStorage.GivePoints:FireClient(plr)
				end 

And the remote is :
– in LOcal script
game.ReplicatedStorage.GivePoints.OnClientEvent:Connect(function()

game.ReplicatedStorage.GivePoints.Server:FireServer()

end)

– in Server script
game.ReplicatedStorage.GivePoints.Server.OnServerEvent:Connect(function(plr)
if plr.leaderstats then
plr.leaderstats.Win.Value = plr.leaderstats.Win.Value + 1
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1
print(“your alive”)
else
print(“no”)
end

end)

When player death, a script rename the leaderstats of death player by “Death”
The remote don’t detect leaderstats, i never see this problem before that, anyone can help me to fix it ?

1 Like

You almost formatted your code correctly :pensive: Also, you can use FireAllClients() instead of putting all the players through a loop

game.ReplicatedStorage.GivePoints:FireAllClients()

Maybe you could try this?

--Local
game.ReplicatedStorage.GivePoints.OnClientEvent:Connect(function()
    game.ReplicatedStorage.GivePoints.Server:FireServer()
    print("Fired")
end)
--in Server script
game.ReplicatedStorage.GivePoints.Server.OnServerEvent:Connect(function(plr)
    if plr:FindFirstChild("leaderstats") then
        plr.leaderstats.Win.Value = plr.leaderstats.Win.Value + 1
        plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1
        print("your alive")
    else
        print("no")
    end
end)

Hi, thanks you, i gonna try that !

Didn’t work, same problem, that print “no” in server. One Player is alive and another one is dead.

Are you sure that the leaderstats thing you’re trying to find is inside the Player object?

1 Like

Sure i have copy your script, the player alive have classic folder called leaderstats, when a player dead he’s leaderstats folder change name by “Death”.

Okay I shall ask this then

Could I see the script that changes the name of the leaderstats folder?

Sure

function dead(playeroof, ok)
	playeroof.Humanoid.Died:connect(function()
		script.ScreenGui:Clone().Parent = ok.PlayerGui
		local player = game:GetService("Players")
		player.CharacterAutoLoads = false
		
		for i, player in pairs(game.Players:GetChildren()) do
			player.leaderstats.Name = "Death"
		end		
		
	end)
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:wait()
	dead(player.Character,player)
	player.CharacterAdded:connect(function(epic)
		dead(epic,player)
	end)
end)
1 Like

Ok wut why are you changing all of the player’s leaderstats names to “Death” whenever a player dies?

Try this:

function dead(playeroof, ok)
	playeroof.Humanoid.Died:connect(function()
		script.ScreenGui:Clone().Parent = ok.PlayerGui
		local player = game:GetService("Players")
		player.CharacterAutoLoads = false
		player.leaderstats.Name = "Death"
		
	end)
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:wait()
	dead(player.Character,player)
	player.CharacterAdded:connect(function(epic)
		dead(epic,player)
	end)
end)

Yeah i just see that in studio by testing with 2 players, i gonna test your script

1 Like

That didn’t work : Screenshot by Lightshot
The leaderstats folder don’t change in Death
Error : “leaderstats” is not a valid members of Players (Players)

Bruh ok lemme rewrite the code

game.Players.PlayerAdded:Connect(function(Player)
    local leaderstats = Player:WaitForChild("leaderstats")
    local PlayerGui = Player:WaitForChild("PlayerGui")

    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")

        Humanoid.Died:Connect(function()
             print("RIP")
             script.ScreenGui:Clone().Parent = PlayerGui
             leaderstats.Name = "Death"
        end)
    end)
end)

wait(20)
game.Players.CharacterAutoLoads = false

Try this and see what you get

1 Like

Okey, gonna try, the AutoLoads is false because in Story Mode, revive is only possible by buying dev product

Screenshot by Lightshot error for CharacterAutoLoads

Ok I edited it, try again perhaps?

That break the load of player when people join the game Screenshot by Lightshot

Inhale

Edited it once again, funny

I have try another thing and just added game.Players.CharacterAutoLoads = false in the death code like that :

game.Players.PlayerAdded:Connect(function(Player)
	local leaderstats = Player:WaitForChild("leaderstats")
	local PlayerGui = Player:WaitForChild("PlayerGui")

	Player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")

		Humanoid.Died:Connect(function()
			print("RIP")
			game.Players.CharacterAutoLoads = false -- Added here
			script.ScreenGui:Clone().Parent = PlayerGui
			leaderstats.Name = "Death"
		end)
	end)
end)

And the print was good “Alive” and “no”, but i gonna try it in game now to tell you if that good or nah

Any update at all? I also would change putting the CharacterAutoLoads to somewhere else client sided

Just put your comment in solution, thanks you Jack !