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

Is there a sollution to these heirachry/ Argument 1 Missing Errors?

1st Script http://prntscr.com/a7b1cs ^ The scrpt named "Script"

Error: 21:38:04.170 - parent is not a valid member of Script 21:38:04.174 - Script 'Workspace.StarterPack.WoodenAxe.SwordScript', Line 31

http://prntscr.com/a7b4tr

r = game:service("RunService") 
ching = false 
sword = script.Parent.Handle 
Tool = script.Parent
lowdamage = Tool.WeaponSettings.MinDamage.Value
maxdamage = Tool.WeaponSettings.MaxDamage.Value
reload = Tool.WeaponSettings.ReloadTime.Value
TotalDur =script.Parent:WaitForChild("TotalDurability")
Dur = script.Parent:WaitForChild("CurrentDurability")


local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav"
SlashSound.Parent = sword
SlashSound.Volume = .7

local LungeSound = Instance.new("Sound")
LungeSound.SoundId = "rbxasset://sounds\\swordlunge.wav"
LungeSound.Parent = sword
LungeSound.Volume = .6

local UnsheathSound = Instance.new("Sound")
UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
UnsheathSound.Parent = sword
UnsheathSound.Volume = 1

 
function blow(hit)
	if ching == true then return end
	
	local humanoid = hit.Parent.Stone:findFirstChild("Resistance"
	)
	print(tostring(humanoid))
	print("1")
	local vCharacter = Tool.Parent
	print("2")
	local vPlayer = game.Players:playerFromCharacter(vCharacter)
	print("3")
	local hum = vCharacter:findFirstChild("Humanoid")
	print("4")
	if humanoid.Value >= 1 then
		print("PICK HIT")
		Dur = Dur - 1
		
		local damage = math.random(lowdamage,maxdamage)
		print(""..damage)
		humanoid.Value = humanoid.Value - damage
		print("Took Damage!!")

	end
end

function tagHumanoid(humanoid, player)
	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = player
	creator_tag.Name = "creator"
	creator_tag.Parent = humanoid
end

function untagHumanoid(humanoid)
	if humanoid ~= nil then
		local tag = humanoid:findFirstChild("creator")
		if tag ~= nil then
			tag.Parent = nil
		end
	end
end


function attack()
	damage = slash_damage
	SlashSound:play()
	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Slash"
	anim.Parent = Tool
end



function swordUp()
	Tool.GripForward = Vector3.new(-1,0,0)
	Tool.GripRight = Vector3.new(0,1,0)
	Tool.GripUp = Vector3.new(0,0,1)
end

function swordOut()
	Tool.GripForward = Vector3.new(0,0,1)
	Tool.GripRight = Vector3.new(0,-1,0)
	Tool.GripUp = Vector3.new(-1,0,0)
end

Tool.Enabled = true
local last_attack = 0
function onActivated()

	if not Tool.Enabled then
		return
	end

	Tool.Enabled = false

	local character = Tool.Parent;
	local humanoid = character.Humanoid
	if humanoid == nil then
		print("Humanoid not found")
		return 
	end

	t = r.Stepped:wait()

	if (t - last_attack < .2) then
		
	else
		attack()
	end

	last_attack = t

	wait(reload)

	Tool.Enabled = true
end


function onEquipped()
	UnsheathSound:play()
end


script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)


connection = sword.Touched:connect(blow)

2nd Script http://prntscr.com/a7b1cs ^Local script named "Local Script"

21:38:43.482 - Value is not a valid member of TextLabel 21:38:43.551 - Script 'Players.Player.Backpack.WoodenAxe.LocalScript', Line 15

http://prntscr.com/a7b3hl

Player = game.Players.LocalPlayer
Gui = Player.PlayerGui:WaitForChild("Durrability"):WaitForChild("Durrability"):WaitForChild("Background"):WaitForChild("DurVal")
Gui2 = Player.PlayerGui.Durrability.Durrability.Background:WaitForChild("DurVal2")
Gui3 = Player.PlayerGui.Durrability.Durrability.Background


Item = script.Parent.Name



script.Parent.Equipped:connect(function() 
	
Gui3.Visible = true	

Gui.Value = Item

Gui2.Value = Item


end)
	
	script.Parent.UnEquipped:connect(function() 
		
		
Gui.Value = ""

Gui2.Value = ""		
		
	Gui3.Visible = false	
		
		
		
end)

Final Scripts

http://prntscr.com/a8genn

Error: 21:37:58.404 - Argument 1 missing or nil 21:37:58.405 - Script 'Players.Player.PlayerGui.Durrability.Durrability.Background.DurVal.DropShadow.LocalScript', Line 5 21:37:58.406 - Stack End 21:37:58.408 - Argument 1 missing or nil 21:37:58.409 - Script 'Players.Player.PlayerGui.Durrability.Durrability.Background.DurVal.LocalScript', Line 5 21:37:58.410 - Stack End

local Item = tostring(script.Parent.Item.Value)

Player = game.Players.LocalPlayer

leaderstats = Player.Backpack:WaitForChild(Item.Value)





Dur = leaderstats.CurrentDurability

while true do
	wait(.1)
	
	script.Parent.Text = Item
	
	
	
	
end



Last

http://prntscr.com/a8geq1

local Item = tostring(script.Parent.Parent.Item.Value)

Player = game.Players.LocalPlayer

leaderstats = Player.Backpack:WaitForChild(Item.Value)





Dur = leaderstats.CurrentDurability

while true do
	wait(.1)
	
	script.Parent.Text = Item
	
	
	
	
end

1 comment

0

On the first script, on line 9, try adding .Value at the end of the line. Also, did you write this all yourself?

2 answers

The first script requires you to be editing a value so at the end of Durability put .Value e.g.

Dur = script.Parent.CurrentDurability.Value

The second script is basically saying the GUI doesn't exist in PlayerGUI, has you misspelt the name of it? If not, make sure it's in StarterGUI.

2 comments

0

It is in the starter gui

0

Actually, that's not recommended. You should put '.Value' in all comparisons or setting of values. If you set Dur to the Value, it won't update when it's changed, and always remain the same.

Use WaitForChild

I cannot stress to you enough the importance of actually waiting for an Instance member before tying to access it, particularly regarding the PlayerGui.

Gui = Player.PlayerGui:WaitForChild("Durrability"):WaitForChild("Durrability"):WaitForChild("Background"):WaitForChild("DurVal");
Gui2 = Player.PlayerGui.Durrability.Durrability.Background:WaitForChild("DurVal2");
Gui3 = Player.PlayerGui.Durrability.Durrability.Background

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