execute store result storage ws:playercount scientists int 2 store result score .science scientist.players if entity @a[team=scientist]
execute if score .science scientist.players matches 5.. run return run title @a[team=scientist] actionbar {"translate":"toomanyplayers","color":"red"}
execute at @e[tag=firstselected,tag=!secondselected,type=interaction] run particle minecraft:wax_on ~ ~0.5 ~-0.3 0.1 0.1 0.1 2 1
execute at @e[tag=secondselected,tag=!firstselected,type=interaction] run particle minecraft:wax_off ~ ~0.5 ~-0.3 0.1 0.1 0.1 2 1
execute at @e[tag=secondselected,tag=firstselected,type=interaction] run particle minecraft:electric_spark ~ ~0.5 ~-0.6 0.1 0.1 0.1 0.3 5
execute as @e[tag=scientist.selector,type=interaction] if data entity @s interaction run function ws:work/misc/tier2/scientist/select
execute as @e[tag=scientist.craft.button,type=interaction] if data entity @s interaction on target run function ws:work/misc/tier2/scientist/craft
execute as @e[tag=scientist.craft.button,type=interaction] if data entity @s interaction run data remove entity @s interaction
execute if entity @a[x=-554,y=41,z=-501,dx=5,dy=4,dz=4] run scoreboard players set .crafting scientist.values 40
scoreboard players remove .crafting scientist.values 1
execute if score .crafting scientist.values matches -1..0 run function ws:work/misc/tier2/scientist/clearcrafting
scoreboard players remove @e[tag=meteorite.layer,tag=meteorite.deactivated,type=item_display,scores={meteorite.cd=1..}] meteorite.cd 1
execute as @e[tag=meteorite.deactivated,type=item_display,scores={meteorite.cd=0}] run function ws:work/misc/tier2/scientist/activatemeteorite
scoreboard players add @e[tag=meteorite.layer,type=item_display,tag=!meteorite.deactivated] meteorite.rotation 1
execute as @e[tag=meteorite.layer,type=item_display,scores={meteorite.rotation=40..},tag=!meteorite.deactivated] run function ws:work/misc/tier2/scientist/rotatemeteorite {rotate:500}
execute as @e[tag=laser.active,type=item_display] run function ws:work/misc/tier2/scientist/rotatelaser
execute if entity @e[tag=laser.active,tag=red_laser,type=item_display] as @e[tag=meteorite.layer,type=item_display] at @s run function ws:work/misc/tier2/scientist/break with entity @s item
execute if entity @e[tag=laser.active,tag=blue_laser,type=item_display] as @e[tag=meteorite.layer,type=item_display] at @s run function ws:work/misc/tier2/scientist/study
execute as @e[tag=insert.capsule,type=interaction] if data entity @s interaction run function ws:work/misc/tier2/scientist/insertcapsule
execute as @e[tag=insert.capsule,type=interaction] if data entity @s interaction run data remove entity @s interaction
execute as @a[team=scientist,scores={scientist.capital=1..}] run function ws:work/misc/tier2/scientist/pay with storage ws:playercount