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

Can't change player's head transparency. Attempt to index nil with "Head". How can i fix it?

local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = game.Players.LocalPlayer.Character

script.Parent.Activated:connect(function()
	Tool.RemoteEvent:FireServer()
	wait(2)
	Character.Head.Transparency = 0
	Character["Left Arm"].Transparency = 0
	Character["Right Arm"].Transparency = 0
	Character["Right Leg"].Transparency = 0
	Character["Left Leg"].Transparency = 0
	Character.Torso.Transparency = 0

end)

1 comment

0

is the remote event supposed to be in the tool itself?

1 answer

change the 1's back to the original number (used for testing)

local Tool = script.Parent

local player = game.Players.LocalPlayer

local Character = player.CharacterAdded:Wait() -- easier way to get the character in my opinion

if player.Character then
	Tool.Activated:Connect(function()
		Tool.RemoteEvent:FireServer()
		wait(2)
	    Character.Head.Transparency = 1
	    Character["Left Arm"].Transparency = 1
	    Character["Right Arm"].Transparency = 1 -- change the 1's back to the original number, i was testing to see if the script works
	    Character["Right Leg"].Transparency = 1
	    Character["Left Leg"].Transparency = 1
	    Character.Torso.Transparency = 1
	end)
end

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