Attempt to call a table value error?

Hello! I made a script to make the character invisible, but it’s not working. I’m not sure why. Whenever it runs, it says “attempt to call a table value” when it gets to “v.LocalTransparencyModifier = NumberSequence{”. I don’t know what to do, because I asked other people and they said the script should work. Heres the script:

workspace.Realm.DescendantAdded:Connect(function(instance)
	if instance:IsA("Model") then
		for i, v in pairs(instance:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("UnionOperation") or v:IsA("Part") and not v.Name == "HumanoidRootPart" then
				v.LocalTransparencyModifier = 1
			elseif v:IsA("ParticleEmitter") then
				v.LocalTransparencyModifier = NumberSequence{
					NumberSequenceKeypoint.new(0, 1),
					NumberSequenceKeypoint.new(0.5, 1),
					NumberSequenceKeypoint.new(1, 1)
				}
			elseif v:IsA("Beam") then
				v.LocalTransparencyModifier = NumberSequence{
					NumberSequenceKeypoint.new(0, 1),
					NumberSequenceKeypoint.new(0.5, 1),
					NumberSequenceKeypoint.new(1, 1)
				}
				end
			end
		end
	end
)

If anyone is able to point out what I did wrong, it would be appreciated! Thank you!

What is Realm and why are you waiting for DescendantAdded? Wouldnt using player.CharacterAdded instead work much better?

1 Like

You simply forgot a .new

v.LocalTransparencyModifier = NumberSequence.new{

Realm is a folder, and I’m using Descendant added because objects are able to spawned within the folder

Let me try it out first, but thanks in advance!

I got this error

What are you trying to do?
LocalTransparencyModifier is a property of BasePart
If you just want to set the Transparency just use Transparency

This is a local script, for some reason whenever I just use regular transparency it just doesn’t work.

LocalTransparencyModifier is really only used for locally setting somethings transparency on a replicated object such as the character (or in older times where filtering enabled could be disabled)

Id just use transparency and bug test from there

That’s what the script looks like with transparency, but it did not work. Do you know what went wrong? There were no errors. [See Below]

Woops sent the wrong script.

workspace.Realm.DescendantAdded:Connect(function(instance)
	if instance:IsA("Model") then
		for i, v in pairs(instance:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("UnionOperation") or v:IsA("Part") and not v.Name == "HumanoidRootPart" then
				v.LocalTransparencyModifier = 1
			elseif v:IsA("ParticleEmitter") then
				v.Transparency = NumberSequence.new{
					NumberSequenceKeypoint.new(0, 1),
					NumberSequenceKeypoint.new(0.5, 1),
					NumberSequenceKeypoint.new(1, 1)
				}
			elseif v:IsA("Beam") then
				v.Transparency = NumberSequence.new{
					NumberSequenceKeypoint.new(0, 1),
					NumberSequenceKeypoint.new(0.5, 1),
					NumberSequenceKeypoint.new(1, 1)
				}
				end
			end
		end
	end
)

What would you count as “not working”
Cause all thats gonna do is make it all invisible

That’s the thing, it didn’t make it invisible. Nothing happened to the particle emitter or the beams. I’m trying to make it invisible

Couldn’t you just do:

v.Transparency = NumberSequence.new(1, 1)

If you’re only setting the 2 default values, you can call the function as normal with the values of each keypoint. You should only use a table when you’re setting multiple keypoints to different values.


For debugging, you can use print to see what the class of v is or to see if a condition passed.

nitpicks

You can shorten this to:

if v:IsA("BasePart") and not v.Name == "HumanoidRootPart" then

Part and UnionOperation inherit from the the BasePart class so it’ll pass true.

Just a couple of small issues with the script

not v.Name == "HumanoidRootPart" this probably doesnt do what you want
Not comes before ==
So its basically doing
not v.Name (which is probably just gonna be false)
false == "HumanoidRootPart

Secondly you dont need to do a whole number sequence to just make it 1
You can just do transparency = NumberSequence.new(1)

Beyond that it works perfectly fine for me when I paste it into a game so it must be a problem with something else

I changed the script, and it still did not do anything. No errors either.

I also changed the script to this, it still did not work.