Hey, I'm quite new to scripting and I don't really know that much. I've been working on a dungeon-styled Roblox boss rush game where if you kill the boss (the npc) and its health is at 0, a part moves upwards which is the door and you can proceed to the next boss room. I looked for tutorials about it but I couldn't find any. Can anyone tell me how to script this, and where to put the script inside?
Hi, to achieve this, you can constantly check if the npc's health is equal to zero and if so, you can tween to door to open.
Here's a script:
-- i made 2 bosses local part1 = game.Workspace.Part1 -- get your 1st door local part2 = game.Workspace.Part2 -- get your second door local TweenService = game:GetService("TweenService") -- this is the tween for the 1st door local part1 = game.Workspace.Part1 -- 1st door local goal = {} goal.Position = Vector3.new(-6.197, 22.353, -67.553) - set the position you want the door to be if it is killed. local tweenInfo = TweenInfo.new(5) -- how long the door takes to fully open, keep it as 5 to make the tween smooth. local tween1 = TweenService:Create(part1, tweenInfo, goal) -- give the information local TweenService = game:GetService("TweenService") -- tween for the 2nd door local part2 = game.Workspace.Part2 -- get your 2nd door local goal = {} goal.Position = Vector3.new(-23.852, 21.838, -66.892) -- set the position you want the door to be if it is killed. local tweenInfo = TweenInfo.new(5) --how long the door takes to fully open, keep it as 5 to make the tween smooth. local tween2 = TweenService:Create(part2, tweenInfo, goal) -- gives information local npc1 = game.Workspace.NPC1 -- get your 1st boss local npc2 = game.Workspace.NPC2 -- get your 2nd boss while true do -- while true do constantly goes in a loop, therefore checking constantly if a boss is killed. if npc1.Humanoid.Health == 0 then -- checks if 1st boss is killed tween1:play() -- plays the tween end if npc2.Humanoid.Health == 0 then -- checks if 2nd boss is killed tween2:play() -- plays the tween end wait() -- keeps from destroying your pc and intense lag end
Hope this helped!
Any questions? just ask!