Character body part material won't change through tool activation

I’m making a script where whenever you drink from a beverage your character body parts change material color (neon). However, I’m not getting output from the script.

Here’s the script:

local Tool = script.Parent
local Handle = Tool.Handle
local Player = Tool.Parent

Tool.Activated:Connect(function()
	wait(1.5)
		Handle.NuclearWaste.Transparency = 1	
		Handle.ic1.Transparency = 1
		Handle.ic2.Transparency = 1
		Handle.ic3.Transparency = 1	
	wait(0.1)
	for i, v in pairs(Player:GetDescendants()) do
		if v:IsA("BasePart") then
			v.Material = Enum.Material["Neon"]
		end
	end
end)	

The transparency toggle in the script works, it’s the for loop I’m having an issue with.

Any help is greatly appreciated, thanks!

Edit: This is a regular script located inside the Tool.

Have you tried using Enum.Material.Neon?

1 Like

I have, unfortunately, it does not work.

This could be why, you defined your Player variable at the start of the script when you should’ve defined it inside the Activated event instead

Can you try this and see if anything changes?

local Tool = script.Parent
local Handle = Tool.Handle

Tool.Activated:Connect(function()
    local Character = Tool.Parent

	wait(1.5)
		Handle.NuclearWaste.Transparency = 1	
		Handle.ic1.Transparency = 1
		Handle.ic2.Transparency = 1
		Handle.ic3.Transparency = 1	
	wait(0.1)
	for i, v in pairs(Character:GetDescendants()) do
		if v:IsA("BasePart") then
			v.Material = Enum.Material.Neon
		end
	end
end)	

Also the Player variable is a bit confusing, so I changed that to the Character instead since you’re getting the Model of the Character

1 Like

You are looking for BaseParts in the player, not the character(player does not contain the character model). Also, you defined player as a the BackPack Service(tools are contained in the player’s backpack service, not the actual player)
To fix this, change:
local Player = Tool.Parent.Parent
Player:GetDescendants to Player.Character:GetDescendants

Actually, don’t let the variable confuse you

When the Player has a Tool equipped in its inventory, it’s automatically set as a Parent inside the Character’s Model (Or game.Workspace.Jackscarlett)

The Activated event would only fire if the Tool has been activated by a “Left Mouse Click” button, so it’d have to be parented inside the Character Model for it to work

A better way to break it down would be to see it as this:

  • The Script would be a Parent of the Tool

  • The Tool would be a Parent of the Character’s Model

  • The Character’s Model would be a Parent of the workspace Service

And so on

In the instance where the OP is attempting to find the Player, it’s instead actually getting what’s inside the Tool’s Parent when it first runs

Oh I didn’t know that, thanks for letting me know!

1 Like