So this may be really simple, but I have no idea how to fix this. And I literally tried everything I can do. This is a new attack script for one of my game. And it keeps saying this:
14:55:38.123 - Players.Player.Backpack.Tremor Punch:95: attempt to index upvalue 'part2' (a nil value) 14:55:38.124 - Stack Begin 14:55:38.125 - Script 'Players.Player.Backpack.Tremor Punch', Line 95 14:55:38.125 - Stack End
Everything is working fine till it gets to that. Which its a local. Here I'll paste the script:
-- Tremor Punch, made by Coldcce.
player = script.Parent.Parent
mouse = player:GetMouse()
animation = script:WaitForChild("Animation")
animation2 = script:WaitForChild("Animation2")
isplaying = false
bin = script.Parent
Backpack = bin.Parent
me = Backpack.Parent
damage = 15
buttonOn = false
char = player.Character
larm = char:FindFirstChild("Left Arm")
rarm = char:FindFirstChild("Right Arm")
enabled = true
local uis = game:GetService("UserInputService") --The service
local plyr = game:GetService("Players").LocalPlayer
local part2 = part2
uis.InputBegan:connect(function(Key, Processed)
if Key.KeyCode == Enum.KeyCode.X and not Processed then
if buttonOn == false then
buttonOn = true
if isplaying == false then
isplaying = true
local animationp = player.Character.Humanoid:LoadAnimation(animation)
animationp:Play()
player.Character.Humanoid.WalkSpeed = 0
wait(1)
local part2 = Instance.new("Part")
part2.BrickColor = BrickColor.new("Light blue")
part2.Parent = larm
part2.Name = "part2"
part2.Size = Vector3.new(2.5, 2.5, 2.5)
part2.TopSurface = "Smooth"
part2.BottomSurface = "Smooth"
part2.FormFactor = "Symmetric"
part2.Shape = "Ball"
part2.Transparency = 0.8
part2.CFrame = larm.CFrame
part2.Material = "Neon"
local f = Instance.new('BodyForce')
f.force = Vector3.new(0, 0, 50)
f.Parent = part2
local Owner = Instance.new("ObjectValue")
Owner.Parent = part2
Owner.Name = "Owner"
Owner.Value = me
local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=315030459"
sound.Parent = part2
sound.Volume=1
sound.Pitch=1
sound:Play()
local e = script.ArrowScript:clone()
e.Parent = part2
e.Disabled = false
local weld = Instance.new("Weld", char)
weld.Part0 = weld.Parent["Left Arm"]
weld.Part1 = part2
weld.C1 = CFrame.fromEulerAnglesXYZ (0, 0, 0) *CFrame.new (0, 1.5, 0)
weld = Instance.new("Weld", char)
weld.Part0 = part2
weld.C1 = CFrame.fromEulerAnglesXYZ (0, 0, 0) *CFrame.new (0, 0, 0)
for i = 1,6 do
wait(0.2)
part2.Transparency = part2.Transparency - 0.1
player.Character.Humanoid.WalkSpeed = 18
end
end
end
uis.InputEnded:connect(function(Key, Processed)
if Key.KeyCode == Enum.KeyCode.X and not Processed then
local animationd = player.Character.Humanoid:LoadAnimation(animation2)
animationd:Play()
player.Character.Humanoid.WalkSpeed = 0
player.Character.Torso.Anchored = true
wait(3)
part2:remove()
player.Character.Torso.Anchored = false
player.Character.Humanoid.WalkSpeed = 16
wait(5)
buttonOn = false
isplaying = false
end
end)
end
end)
I've tried local, global at the top, workspace global, and all of that. I don't know everything yet. I'm still learning this Roblox Scripting stuff.
I've been trying to fix this problem last night around 4-6 AM. And non of it worked. I've been trying for a hour now to fix it too. Nothing has worked.
Someone please help me.

2 comments
You defined part2 twice in your script. I believe you were only suppose to define it once for the part to be created through the instance.
Yea, I fixed that after I posted this. Thank you minikitkat! :D