Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Character clothing resets on death? How would I make it so It doesnt reset on death?

I have a button and when you press it, it basically makes your character look like santa. But the problem is when you die your player obviously resets so you no longer look like santa.

How would you go about making the clothing a permanent change until the clothing was deleted by another script.

Heres the script that changes the way your character looks, it does more than just change your character so try to ignore the other stuff.

local replicatedstorage = game:GetService("ReplicatedStorage")
local givetool = replicatedstorage:WaitForChild("GiveThompson")
local player = game.Players.LocalPlayer

local button = script.Parent:WaitForChild("Play")
local clothingstorage = game.Workspace.Clothing
local shirt = clothingstorage:FindFirstChild("SantaShirt")
local pants = clothingstorage:FindFirstChild("SantaPants")

button.MouseButton1Click:connect(function()
	givetool:FireServer()
	script.Parent.Parent.Enabled = false
	player.Character:FindFirstChild("Pants"):Destroy()
	player.Character:FindFirstChild("Shirt"):Destroy()
	shirt:Clone().Parent = player.Character
	pants:Clone().Parent = player.Character
	wait(1)
	script.Parent.Parent:Destroy()
end)

Hopefully someone can help me out, I know it cant be too complex. I think I may be over thinking it, I was gonna go and custom load characters and on loading the character check which GUI they pressed and then set the clothing accordingly. But ive seen some very basic games have clothing through death so it cant be to complex.

Thank you for your time hopefully we can solve this problem :)

1 answer

You could use the PlayerAdded, CharacterAdded, and Died events on the server to track whenever a player dies. Change them back to a santa if they were one

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(c)
		c:WaitForChild("Humanoid").Died:Connect(function()
			plr.CharacterAdded:Wait();
			print("spawned after death");
			--Turn into santa again if they were one
		end)
	end)
end)

5 comments

0

What if I was using a stringvalue. And when they pressed the button to become santa, it parented the stringvalue to the player. And then changed the stringvalue to 1. Would the script above still work?

0

Also whats the difference between "connect" and "Connect" because ive always just used the lowercase one.

0

There's also a value called 'LoadCharacterAppearance' in the StarterPlayer - it stops players loading their custom char.

0

That works but it doesnt keep it after death @hiccup111. I wanna keep how to player looks after death.

0

You could use a StringValue but that's one more StringValue entity for every client in the game. Not necessary. And the difference between the two functions is that connect is deprecated while Connect isn't.

This discussion is preserved as it was. New answers, comments, and votes are closed.