Workspace.Barrel.Head.Script:4: attempt to call a table value?

Hey there, im trying to make an exploding barrel that will take damage or explode based on velocity

local function OnTouchy()
	local velo = script.Parent.Velocity
	
	if velo <= Vector3(30,30,30) or script.Parent.Parent.Humanoid.Health < 60 then
		local explode = Instance.new("Explosion")
		explode.Position = script.Parent
		explode.BlastRadius = 60
		explode.BlastPressure = 3000
		
		
		for i = 1, 30 do
			local Debris = game:GetService("Debris")
			local Part = Instance.new("Part")
			Part.Size = Vector3.new(math.random(0.25,1),math.random(0.25,1),math.random(0.25,1))
			Part.Parent = script.Parent
			Part.Position = script.Parent.Position
			Part.CanCollide = true
			Part.Velocity = Vector3.new(math.random(0.25,30),math.random(0.25,70),math.random(0.25,68))
			Debris:AddItem(Part, 7)
		end
		script.Explosion6:Play()
		script.Parent.Parent:Destroy()
	end
end
script.Parent.Touched:Connect(OnTouchy)

yes i know this code is incredible innefficient, im new to roblox lua

Can you tell us what the erroring line is?

line 4

spacefillerspacefillerspacefillerspacefiller

You cannot call Vector3() itself. You need to call it’s constructor function Vector3.new()

Replace the 4th line with this:

if velo <= Vector3.new(30,30,30) or script.Parent.Parent.Humanoid.Health < 60 then
1 Like

i was just gonna say that


this text will be blurred

2 Likes

Ah thanks, i spent literally 20 minutes fixing that :sweat_smile:

1 Like