So, im trying to make a boss prototype for my game, but I cant figure out how to make the boss be able to take damage(Its a part spawned using an Instance.new function)
Here is the following script
function SpawnBoss() local BossSpawn = Instance.new("Part", workspace) BossSpawn.Size = Vector3.new(26.121, 44.027, 26.311) BossSpawn.Position = Vector3.new(25,0,5) BossSpawn.Color = Color3.fromRGB(0,0,0) BossSpawn.Name = "Boss" return SpawnBoss() end local Boss = game.Workspace:FindFirstChild("Boss") script.Parent.MouseButton1Click:Connect(function() local SpawnBossAct = SpawnBoss() SpawnBossAct.Touched:Connect(function() local plr = game.Players.LocalPlayer local character = plr.Character or plr.CharacterAdded:wait() local humanoid = character:WaitForChild("Humanoid") local maxHp = humanoid.MaxHealth humanoid.Health = maxHp - math.random(20,60) --I want to make it here so that when the player also touches the Boss, the boss takes damage but im not sure how to add health to the boss(Part) end) end)