hello im new and learning scripting, how do i make a script when new player click “Play” at main menu they will go to character customization or selection, if the player played the game before the character customization will skip and just spawn and also how do i save players custom character when they leave, thx
You can achieve the “skip for players that already have custom character” using DataStoreService:
First enable Data Stores:
- Go to Home > Game Settings > Security.
- Enable the Enable Studio Access to API Services toggle.
- Click Save.
Here is an example script snippet
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerExperience")
local success, errorMessage = pcall(function()
experienceStore:SetAsync("User_1234", 50)
end)
if not success then
print(errorMessage)
end
For detecting when player leaves, you can do the following:
local Players = game:GetService("Players")
Players.PlayerRemoving:Connect(function(player)
print(player .. "is leaving the game!")
end)
More info can be found here: Data stores | Documentation - Roblox Creator Hub
As for character customization, you can do the following:
- Create a Rig in the workspace and call it whatever you want, like “CustomCharacter” or something. Remember the name you put.
- Create a rig of the custom character you want (without any accessories, just the base rig). Name it
StarterCharacter
and put it in StarterPlayer - In your script, you can set the camera to
Scriptable
and change the camera’s position and orientation depending on where the rig is located. - Create a UI with ImageLabels or ViewportFrames of the accessories or hairs or whatever you want to let players be able to put on their character. When a player clicks a button, you can parent an accessory instance or other to the rig.
- Make a table in your script that keeps tract of what accessories or character customization the player has chosen. When the player spawns apply those to the character.
1 Like
Thank u and how can i give a player a value/data or something when a gui button is clicked?
They said data store can’t work in a local script.
And how can i like reset or clear my data because i want to test it again
Thx.