Need help changing character based on join date

I need help with a script that changes a players starter character based on when they joined roblox. For example if you joined when guests where a thing you would be a guest or if you are new then a bacon.

Current progress:

local Players = game:GetService("Players")
local ServStor = game:GetService("ServerStorage")
local StarterPlayer = game:GetService("StarterPlayer")
local Characters = ServStor:WaitForChild("characters")

local function getJoinDate(player)
	local joinTime = os.time() - (player.AccountAge * 86400)
	return os.date("!*t", joinTime)
end


local function getCharacterForJoinDate(joinDate)
	local year = joinDate.year
	local month = joinDate.month

	if year <= 2010 then
		if year <= 2007 then
			return Characters:FindFirstChild("TemplateR6")
		else
			return Characters:FindFirstChild("TemplateR6")
		end
	elseif year <= 2014 then
		return Characters:FindFirstChild("TemplateR6")
	elseif year <= 2017 then
		if month <= 6 then
			return Characters:FindFirstChild("TemplateR6")
		else
			return Characters:FindFirstChild("TemplateR6")
		end
	elseif year <= 2020 then
		return Characters:FindFirstChild("TemplateR6")
	else
		if year >= 2023 then
			return Characters:FindFirstChild("TemplateR6")
		else
			return Characters:FindFirstChild("TemplateR6")
		end
	end
end
1 Like

What do you need help with exactly?

making the part that sets the starter character for the specific player

I’m just going to simplify this script for explanation purposes, but all you need to do is reassign the character before spawning them in.

local player = Players.LocalPlayer -- or however you get the player
local joinDate = getJoinDate(player)
local character = getCharacterForJoinDate(joinDate)

player.Character = character
character.Parent = game.Workspace -- or wherever you want to put it

^^ I did an edit, player:LoadCharacter() won’t work here.

so it should be run as a local script right?

Should i place it in starter character or player scripts

No, you’d have to do this in a regular script.
Probably in ServerScriptService, StarterCharacter wouldn’t work (for obvious reasons) and StarterPlayer is local only.

oh, ok. thank you for the help.

1 Like

hold on, this is a script, cant get local player

In that case, you need to put this in a:

game:GetService("Players").PlayerAdded:Connect(function(player)

If you are doing this, make sure CharacterAutoLoads is not on!

how do i disable character autoload

never mind, i found it. thank you

1 Like

I did everything but didn’t work, close tho.

local Players = game:GetService("Players")
local ServStor = game:GetService("ServerStorage")
local StarterPlayer = game:GetService("StarterPlayer")
local Characters = ServStor:WaitForChild("characters")

local function getJoinDate(player)
	local joinTime = os.time() - (player.AccountAge * 86400)
	return os.date("!*t", joinTime)
end

game:GetService("Players").PlayerAdded:Connect(function(player)
	
	local joinDate = getJoinDate(player)
	local year = joinDate.year
	local month = joinDate.month

	if year <= 2010 then
		if year <= 2007 then
			player.Character = Characters:FindFirstChild("TemplateR6")
		else
			player.Character = Characters:FindFirstChild("TemplateR6")
		end
	elseif year <= 2014 then
		player.Character = Characters:FindFirstChild("TemplateR6")
	elseif year <= 2017 then
		if month <= 6 then
			player.Character = Characters:FindFirstChild("TemplateR6")
		else
			player.Character = Characters:FindFirstChild("TemplateR6")
		end
	elseif year <= 2020 then
		player.Character = Characters:FindFirstChild("TemplateR6")
	else
		if year >= 2023 then
			player.Character = Characters:FindFirstChild("TemplateR6")
		else
			player.Character = Characters:FindFirstChild("TemplateR6")
		end
	end
end)

What doesnt work? And have you tried moving the character outside of serverstorage?

You need to clone your model to workspace before setting the player’s character to it.

I recommend moving from os.time and os.date to DateTime.
I HIGHLY recommend taking the if-else stack and replacing it with a table!

I set up a character change function for you, please see it fit to change the script to your needs.

local Players = game:GetService("Players")
local ServStor = game:GetService("ServerStorage")
local Characters = ServStor:WaitForChild("characters")

local function getJoinDate(player)
	local Date = DateTime.fromUnixTimestamp(DateTime.now().UnixTimestamp - (player.AccountAge * 86400))
	return Date:ToUniversalTime()
end

local function setCharacter(player : Player, template : Model)
	local templatemodel = template:Clone()
	templatemodel.Parent = workspace
	player.Character = templatemodel
end

local function playerJoined(player)

	local JoinDate = getJoinDate(player)
	local Year = JoinDate["Year"]
	local Month = JoinDate["Month"]
	
	if Year <= 2010 then
		if Year <= 2007 then
			setCharacter(player,Characters:FindFirstChild("TemplateR6"))
		else
			setCharacter(player,Characters:FindFirstChild("TemplateR6"))
		end
	elseif Year <= 2014 then
		setCharacter(player,Characters:FindFirstChild("TemplateR6"))
	elseif Year <= 2017 then
		if Month <= 6 then
			setCharacter(player,Characters:FindFirstChild("TemplateR6"))
		else
			setCharacter(player,Characters:FindFirstChild("TemplateR6"))
		end
	elseif Year <= 2020 then
		setCharacter(player,Characters:FindFirstChild("TemplateR6"))
	else
		if Year >= 2023 then
			setCharacter(player,Characters:FindFirstChild("TemplateR6"))
		else
			setCharacter(player,Characters:FindFirstChild("TemplateR6"))
		end
	end
end

Players.PlayerAdded:Connect(playerJoined)

so now when spawning it clones the character into workspace then it disappears after your camera cuts to it for a sec followed by you spawning in but not as the character.

You need to turn off CharacterAutoLoads in the Player service.

Click on the Players service in your Explorer and scroll to the bottom, and then uncheck “CharacterAutoLoads”.

Please also note that you need a valid Humanoid for your character of choice and you need to have it unanchored, It’s also recommended that you set the TemplateR6 position to the spawn point.

That was not the issue, it just tps you to the characters last location as the character then resets you back at the spawn with no skin

local Players = game:GetService("Players")
local ServStor = game:GetService("ServerStorage")
local Characters = ServStor:WaitForChild("characters")

local function getJoinDate(player)
	local Date = DateTime.fromUnixTimestamp(DateTime.now().UnixTimestamp - (player.AccountAge * 86400))
	return Date:ToUniversalTime()
end

local function setCharacter(player : Player, character : Model)
	local characte = character:Clone()
	warn("clone")
	warn(player)
	characte.Parent = workspace
	player.Character = characte
end

local function playerJoined(player)

	local JoinDate = getJoinDate(player)
	local Year = JoinDate["Year"]
	local Month = JoinDate["Month"]
	
	warn(Year, Month)

	if Year <= 2010 then
		if Year <= 2007 then
			setCharacter(player,Characters:FindFirstChild("TempR6"))
			warn("1")
		else
			setCharacter(player,Characters:FindFirstChild("TempR6"))
			warn("2")
		end
	elseif Year <= 2014 then
		setCharacter(player,Characters:FindFirstChild("TempR6"))
		warn("3")
	elseif Year <= 2017 then
		if Month <= 6 then
			setCharacter(player,Characters:FindFirstChild("TempR6"))
			warn("4")
		else
			setCharacter(player,Characters:FindFirstChild("TempR6"))
			warn("5")
		end
	elseif Year <= 2020 then
		setCharacter(player,Characters:FindFirstChild("TempR6"))
		warn("6")
	else
		if Year >= 2023 then
			setCharacter(player,Characters:FindFirstChild("TempR6"))
			warn("7")
		else
			setCharacter(player,Characters:FindFirstChild("TempR6"))
			warn("8")
		end
	end
end

Players.PlayerAdded:Connect(playerJoined)

Could it be possible to show us the hierarchy of the TempR6 model?

it aint that, i used a copy of my own character