I made a script but when i try to add the health into the npc this is my script

local v1 = nil;
selected = "";
local l__LocalPlayer__2 = game.Players.LocalPlayer;
local l__Team__3 = l__LocalPlayer__2.Team;
while true do
	wait();
	v1 = l__LocalPlayer__2.Team;
	if v1 ~= nil then
		break;
	end;
end;
local u1 = v1;
function lock()
	u1 = l__LocalPlayer__2.Team;
	if u1.Name == "Host" then
		script.Parent.Visible = true;
		return;
	end;
	script.Parent.Visible = false;
end;
l__LocalPlayer__2.Changed:Connect(function()
	lock();
end);
script.Parent.Changed:Connect(function()
	lock();
end);
lock();
script.Parent.Red.MouseButton1Down:Connect(function()
	script.Parent.Display.Text = workspace.NPCS.RedNPC.Humanoid.Health;
	selected = "RedNPC";
end);
script.Parent.Yellow.MouseButton1Down:Connect(function()
	script.Parent.Display.Text = workspace.NPCS.YellowNPC.Humanoid.Health;
	selected = "YellowNPC";
end);
script.Parent.Green.MouseButton1Down:Connect(function()
	script.Parent.Display.Text = workspace.NPCS.GreenNPC.Humanoid.Health;
	selected = "GreenNPC";
end);
script.Parent.Blue.MouseButton1Down:Connect(function()
	script.Parent.Display.Text = workspace.NPCS.BlueNPC.Humanoid.Health;
	selected = "BlueNPC";
end);
script.Parent.Add.MouseButton1Down:Connect(function()
	script.Parent.Display.Text = script.Parent.Display.Text + 1000;
end);
script.Parent.Subtract.MouseButton1Down:Connect(function()
	script.Parent.Display.Text = script.Parent.Display.Text - 1000;
end);
local l__UpdateHealth__2 = game.ReplicatedStorage.UpdateHealth;
script.Parent.RedEnter.MouseButton1Down:Connect(function()
	l__UpdateHealth__2:FireServer(workspace.NPCS.RedNPC.Humanoid, script.Parent.Display.Text);
end);
script.Parent.YellowEnter.MouseButton1Down:Connect(function()
	l__UpdateHealth__2:FireServer(workspace.NPCS.YellowNPC.Humanoid, script.Parent.Display.Text);
end);
script.Parent.GreenEnter.MouseButton1Down:Connect(function()
	l__UpdateHealth__2:FireServer(workspace.NPCS.GreenNPC.Humanoid, script.Parent.Display.Text);
end);
script.Parent.BlueEnter.MouseButton1Down:Connect(function()
	l__UpdateHealth__2:FireServer(workspace.NPCS.BlueNPC.Humanoid, script.Parent.Display.Text);
end);

1 comment

0

Does it throw an error? If it does what is it?