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

Why does it say "Value is not a valid member of Model", etc. in out put?

Why does it say in output: "17:13:42.515 - Value is not a valid member of Model", "17:13:42.515 - Script 'Workspace.Player1.StarterSword.Handle.LocalScript', Line 13", and "17:13:42.515 - Stack End". The NPC has the value inside of him. How can I fix this?

local debounce = false
local player = game.Players.LocalPlayer

function onTouched(hit)
	if not debounce then
		debounce = true
		if hit.Parent.Name:sub(1,17) == "AFK Noob Lv 1 HP " then
			hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
			if hit.Parent.Humanoid.Health == 0 then
				if hit.Parent.Value == false then 
					player.leaderstats.EXP.Value = player.leaderstats.EXP.Value + 16 
				end
				hit.Parent.Value = true
			end
			wait(0.5)
			debounce = false
		elseif hit.Parent.Name:sub(1,4) == "Noob" then
			hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
			wait(0.5)
			debounce = false
        end
    end
end

script.Parent.Touched:connect(onTouched)

1 answer

✓ Accepted answer

You forgot to set the value to change! Use hit.Parent.Value.Value instead. Also in the if statement it is better practice to use findFirstChild("Value") rather than .value!

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