How to apply logic to pre-existing players?

I have a serverscript, that uses a module to randomize a character’s appearance when they first join a server. But the primary issue is that it doesn’t “create” a character for the ‘older’ players if they are the newest player until after they respawn.
For example,
Player 1, 2, and 3 join the game.
Player 1 will be able to see everyone’s character as they join first, Player 2 won’t be able to see Player 1, and Player 3 cannot see Player 2 and 1’s characters.

I’ve been trying to figure out what would be the best method to fix the issue.

local NoidCharacterHandler = require(game:GetService("ReplicatedStorage").NoidCharacterHandler)
local serverToClientRequest = game:GetService("ReplicatedStorage"):WaitForChild("ServerToAllClientsBody")
local players = game:GetService("Players")

local shapeTypes = {
	"Squarnoid",
	"Wedgnoid",
	"Sphernoid",
	"Cylindnoid"
}

players.PlayerAdded:Connect(function(player)
	
	--determining noid shape, omitted
	
	--coloring the noid logic, omitted
	
	NoidCharacterHandler:CreatePlayerNoid(player,{
		noidShape = noidShape,
		color = color
	})
	
	player.CharacterAdded:Connect(function(character)
		
		--packet, is a table that holds noidShape and color for character creation.
		
		serverToClientRequest:FireAllClients(player, packet)
	end)
end)

Is the character randomized on client side or server?

Based on the issue, I’m going to assume that you’re randomizing the characters on the client. A way to fix this while still using the same environment would just be to add code that loops through all the current players on the new player’s client. If you want the randomized characters to be the same on all clients, probably just handle the whole thing on the server at that point.

The character’s randomization is handled on the server, and then sent to the client of everyone to make the character on everyones client, just so the server doesnt have to handle extra details.
@SleepyyRico

I dont think it will cause server any major problems. Maybe just do it on the server’s side then there wont be problems with client seeing different things etc.

1 Like

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