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

Owner character changer wont work. How do I fix this?

I work for this small cafe as a developer, and the owner wanted me to make this weird script that made his whole body neon and red when he joined the game. What happens is that when I went on a test game, it didn't work, and yes I put my name in the local variable owner.

Here's the script:


while true do
	wait(1)
	local owner = "owner's name"
	local ownerfind = game.Workspace:FindFirstChild(owner)
	if ownerfind then
		ownerfind.Head.BrickColor = BrickColor.new("Really red")
		ownerfind.Head.Mesh:Destroy()
		ownerfind.Head.Material = "Neon"
		local hatdelete = game.Workspace.owner:FindFirstChildWhichIsA("Accessory")
		if hatdelete then
			hatdelete:Destroy()
			hatdelete:Destroy()
			hatdelete:Destroy()
		end
		ownerfind["Left Arm"].BrickColor = BrickColor.new("Really red")
		ownerfind["Left Arm"].Material = "Neon"
		ownerfind["Right Arm"].BrickColor = BrickColor.new("Really red")
		ownerfind["Right Arm"].Material = "Neon"
		ownerfind["Left Leg"].BrickColor = BrickColor.new("Really red")
		ownerfind["Left Leg"].Material = "Neon"
		ownerfind["Right Leg"].BrickColor = BrickColor.new("Really red")
		ownerfind["Right Leg"].Material = "Neon"
		ownerfind["Torso"].BrickColor = BrickColor.new("Really red")
		ownerfind["Torso"].Material = "Neon"
		
		
end

end

2 answers

✓ Accepted answer

Here is a simple thing I put together.

local owner = "ForeverBrown"

game.Players.PlayerAdded:Connect(function(player)
	if player.Name == owner then
		player.CharacterAppearanceLoaded:Connect(function(character)
			for i,v in pairs(character:GetChildren())do
				if v:IsA("Accessory") or v:IsA("Pants") or v:IsA("Shirt") or v:IsA("BodyColors") then print('removed') v:Destroy() end
				if v:IsA("MeshPart") or v:IsA("Part") then
					v.BrickColor = BrickColor.new("Really red")
					v.Material = Enum.Material.Neon
				end
			end
		end)
	end
end)

This will account for both R6 and R15 rigs and will likely support any rig Roblox throws at us in the future.

1 comment

0

Let me know if this works for your need.

There's gonna be alot of things I might talk about.

Please consider opening the output in the view tab.

Line 9. Use workspace[owner] because even if owner is a variable, indexing workspace with a period means workspace should return an instance with the name "owner", which there isn't.

Using brackets to index is different. Here's a comparison.

local a=workspace.Terrain;
local b=workapace['Terrain'];
print(a==b);--true

Notice how I can use a string and brackets to get terrain. That means any string in those brackets is what shall workspace return based from name. So if I wanna get a part named "Part Part", I can't use workspace.Part Part because it can be misinterpreted as two different statements. Therefore I would use a bracket and a string. workspace['Part Part']

3 comments

0

Note this solution was done on mobile so correct me if im wrong

0

What else are you going to talk about? ... although this answer is correct I think it is better to just run the code once when the character is created.

0

I didnt have enough time to takj about his method

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