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

script attempt to index nil with value ?

it just doesnt works, i try to get the string value but it just returns this error, it works on other games, even with no findfirstchild, but it just doesnt works here, the sword works fine tho

the error is at line 31

script.Parent.OnServerEvent:Connect(function(plr)
	if plr.Data.Weapon.Value == "Sword" then
		local char = plr.Character
		local anim = char:FindFirstChild("Humanoid"):LoadAnimation(script.Swing)
		anim:Play()
		pcall(function()
			char.Sword.Trail.Enabled = true
			wait(.3)
			char.Sword.Trail.Enabled = false
		end)
		for i,v in pairs(workspace:GetChildren()) do
			if v.Name ~= char.Name then
				if v:FindFirstChild("Enemy") then
					if (char.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 8 then
						v.Enemy.Health -= 20
						v.LastToHit.Value = char.Name
						local sound = script.Sound:Clone()
						sound.Parent = char.HumanoidRootPart
						sound:Play()
						game.Debris:AddItem(sound,1)
					end
				end
			end
		end
	elseif plr.Data.Weapon.Value == "Bow" then
		local char = plr.Character
		local anim = char:FindFirstChild("Humanoid"):LoadAnimation(script.Bow)
		anim:Play()
		local arrow = game.ServerStorage.ArrowF:Clone()
		arrow.Parent = workspace
		arrow:FindFirstChild("Player").Value = char.Name
		arrow.Position = char.HumanoidRootPart.Position
		arrow.Orientation = char.HumanoidRootPart.Orientation
		local bv = Instance.new("BodyVelocity",arrow)
		bv.Velocity = char.HumanoidRootPart.CFrame.LookVector * 40
		bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		game.Debris:AddItem(arrow,5)
	end
end)

please someone help me, if you need more information comment

1 answer

✓ Accepted answer

Instead of

arrow:FindFirstChild("Player")

-- Try

arrow.Parent:FindFirstChild("Player")

It's like your saying that there is a value inside of the arrow. ( Which I don't know if there is or not )

5 comments

0

there is a value inside of the arrow

0

Oh

0

the arrow is a part not a model

0

OH IM DUMB, THE VALUE IS INSIDE OF A SCRIPT INSIDE OF THE ARROW... i will just accept this answer

0

Oh well ok no problem

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