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

Attempt to call a table value, how to fix this?

So I'm making an explosion, but this problem appears every time I try to detonate it. Basically, I want a particle that appears at a certain height but can't make it work.

---the part where the particleemitter is
local airwave = Instant("Part")
Services.Debris:AddItem(airwave,6)
airwave.Locked = true
airwave.Anchored = true
airwave.CanCollide = false
airwave.Size = Vector3.new(0,0,0)
airwave.CFrame = Cframe(Explosion_Position)+CFrame(0, 50, 0)-- here is the position and the plus height above the explosion(i want it to appear at the top of the explosion)
airwave.Name = "airwave"
airwave.Massless = true
airwave.Transparency = 1
--the particleemitter
local airwave_particle = Instance.new("ParticleEmitter")
airwave_particle.TextureId = "rbxassetid://9367191410"
airwave_particle.Scale = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(1, 400) });
airwave_particle.Offset = Vector3.new(0,0,0)
airwave_particle.Name = "AIRWAVE_PARTICLE"
airwave_particle.Parent = airwave
airwave:Emit(2);

1 answer

✓ Accepted answer

line 8: airwave.CFrame = Cframe(Explosion_Position)+CFrame(0, 50, 0)

the first Cframe where the "f" is lowercase is fine if you have the line Cframe = CFrame.new before it is called. storing Instance classes as variables allow this to work.

however, as you are setting the CFrame of airwave, you can only have it equal one CFrame value. the second part of the line adds CFrame(0, 50, 0), and you cannot call CFrame itself; you have to use CFrame.new() or another constructor of CFrame for proper code. CFrame is also a table that consists of components that describe 3D positions and orientations, hence the error "Attempt to call a table value."

plus, because airwave.CFrame cannot be assigned as two added CFrames, you should write:

airwave.CFrame = Cframe(Explosion_Position)+Vector3.new(0, 50, 0)

because Vector3 is not read-only like CFrame is, and adding a Vector3 value to a CFrame value will equal one CFrame value, which you can assign to airwave.CFrame.

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