Script Changes wont stay after Player Resets

What do you want to achieve?

I have 2 scripts, that change the players avatar, based on name and player ID. I want those changes to STAY, after they reset.

What is the issue?

After the player resets, all the changes go back to the basic thing.
Example: The main StarterCharacter’s suit is yellow, but in a script, it is set that my player ID, makes mine Green. It makes it green when I spawn in, but after I reset, it goes to that basic yellow.

Player Name Script:
image

Player ID Script:
image

What solutions have you tried so far?
Asked a couple scripter friends about it, no answer.

The scripts work, and do what I want, but they don’t stay. After I reset, both go back to the things they were before. I’m not a great scripter, I am more of a builder.

1 Like

Well, You have PlayerAdded Functions, which only triggers when a player is added, and not on reset… Let me see what A fix can be, but it would be another function

Try a game.Players.CharacterAdded:Connect(function) Instead of PlayerAdded

1 Like

Your script seems to only activate when a player joins the game. When a player resets, only their character resets, the player is readded, and thus the script won’t be activated.

I’m not sure if this is the best approach, but you can consider using

game.Workspace.ChildAdded:Connect(function(character)

Then check if that character is a player.

4 Likes

Can have really weird false positives and can trigger a ton causing lag. Like with an Anti-cheat system I had, The force field was acting weird when I tried that. So just be aware, but can be doable with finding if it is a character. Just can act weird

This worked! Thank you so much!

2 Likes

It has fixed my name issue, but it sadly doesn’t work for the User ID script.

This can be fixed. You have to rewire a couple of things… let me show you how to find the UserId from a character

You can find the Id of a Character by doing this!

local NewPlayer = game.Players:GetPlayerFromCharacter(character)
local Id = NewPlayer.UserId

(This was my own test)

I am trying to only give a certain thing to a certain player. Would I just be able to do something like:

if Id == [specific ID] then
[Insert rest of code here]

you can keep the script you had about and do

 table.find(phatomID, Id)

Unless there is errors in the output, then please share

Didnt mean to mark that as a solution mb lol. It didn’t work, no errors either, but this time it didn’t change the color at all

Can you put your current script in right now?

I am trying to look for the error but many edits have happened so I need an update on what it looks like

Sorry, I put it in the wrong place, so it still shows up when I spawn, but not when I reset.

image

I may be interpreting it wrong, but it still appears that the script is only firing when a player joins the game.

you kept it a PlayerAdded Event. like we talked before above, it only fires once per a player :slight_smile:

Your piece of code fixed my other script, but it didn’t seem to work for this one, so I am following the steps the other guy is telling me to do.

Yes but, game.Players.CharacterAdded, doesnt work.

game.Workspace.ChildAdded:Connect(function(child)
	if game.Players:FindFirstChild(child.Name) then
	
		local player = game.Players:FindFirstChild(child.Name)
		local playerId = player.UserId
		
	end
end)
1 Like